~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/rpl_tblmap.cc

  • Committer: Monty Taylor
  • Date: 2008-07-05 16:23:40 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: monty@inaugust.com-20080705162340-an09yicpupdtwo2m
Fixed simple signdedness problem.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include <drizzled/server_includes.h>
17
 
 
18
 
#include <drizzled/replication/tblmap.h>
19
 
 
 
16
#include "mysql_priv.h"
 
17
 
 
18
#ifdef HAVE_REPLICATION
 
19
 
 
20
#include "rpl_tblmap.h"
 
21
 
 
22
#define MAYBE_TABLE_NAME(T) ((T) ? (T)->s->table_name.str : "<>")
20
23
#define TABLE_ID_HASH_SIZE 32
21
24
#define TABLE_ID_CHUNK 256
22
25
 
43
46
  free_root(&m_mem_root, MYF(0));
44
47
}
45
48
 
46
 
Table* table_mapping::get_table(ulong table_id)
 
49
st_table* table_mapping::get_table(ulong table_id)
47
50
{
 
51
  DBUG_ENTER("table_mapping::get_table(ulong)");
 
52
  DBUG_PRINT("enter", ("table_id: %lu", table_id));
48
53
  entry *e= find_entry(table_id);
49
54
  if (e) 
50
55
  {
51
 
    return(e->table);
 
56
    DBUG_PRINT("info", ("tid %lu -> table 0x%lx (%s)", 
 
57
                        table_id, (long) e->table,
 
58
                        MAYBE_TABLE_NAME(e->table)));
 
59
    DBUG_RETURN(e->table);
52
60
  }
53
61
 
54
 
  return(NULL);
 
62
  DBUG_PRINT("info", ("tid %lu is not mapped!", table_id));
 
63
  DBUG_RETURN(NULL);
55
64
}
56
65
 
57
66
/*
80
89
  return 0;
81
90
}
82
91
 
83
 
int table_mapping::set_table(ulong table_id, Table* table)
 
92
int table_mapping::set_table(ulong table_id, TABLE* table)
84
93
{
 
94
  DBUG_ENTER("table_mapping::set_table(ulong,TABLE*)");
 
95
  DBUG_PRINT("enter", ("table_id: %lu  table: 0x%lx (%s)", 
 
96
                       table_id, 
 
97
                       (long) table, MAYBE_TABLE_NAME(table)));
85
98
  entry *e= find_entry(table_id);
86
99
  if (e == 0)
87
100
  {
88
101
    if (m_free == 0 && expand())
89
 
      return(ERR_MEMORY_ALLOCATION); // Memory allocation failed      
 
102
      DBUG_RETURN(ERR_MEMORY_ALLOCATION); // Memory allocation failed      
90
103
    e= m_free;
91
104
    m_free= m_free->next;
92
105
  }
93
106
  else
94
 
    hash_delete(&m_table_ids,(unsigned char *)e);
 
107
    hash_delete(&m_table_ids,(uchar *)e);
95
108
 
96
109
  e->table_id= table_id;
97
110
  e->table= table;
98
 
  my_hash_insert(&m_table_ids,(unsigned char *)e);
 
111
  my_hash_insert(&m_table_ids,(uchar *)e);
99
112
 
100
 
  return(0);            // All OK
 
113
  DBUG_PRINT("info", ("tid %lu -> table 0x%lx (%s)", 
 
114
                      table_id, (long) e->table,
 
115
                      MAYBE_TABLE_NAME(e->table)));
 
116
  DBUG_RETURN(0);               // All OK
101
117
}
102
118
 
103
119
int table_mapping::remove_table(ulong table_id)
105
121
  entry *e= find_entry(table_id);
106
122
  if (e)
107
123
  {
108
 
    hash_delete(&m_table_ids,(unsigned char *)e);
 
124
    hash_delete(&m_table_ids,(uchar *)e);
109
125
    /* we add this entry to the chain of free (free for use) entries */
110
126
    e->next= m_free;
111
127
    m_free= e;
120
136
*/
121
137
void table_mapping::clear_tables()
122
138
{
123
 
  for (uint32_t i= 0; i < m_table_ids.records; i++)
 
139
  DBUG_ENTER("table_mapping::clear_tables()");
 
140
  for (uint i= 0; i < m_table_ids.records; i++)
124
141
  {
125
142
    entry *e= (entry *)hash_element(&m_table_ids, i);
126
143
    e->next= m_free;
127
144
    m_free= e;
128
145
  }
129
146
  my_hash_reset(&m_table_ids);
130
 
  return;
 
147
  DBUG_VOID_RETURN;
131
148
}
 
149
 
 
150
#endif