~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/blackhole/ha_blackhole.cc

Merged in changes from Andrey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
 
47
47
static const char *ha_blackhole_exts[] = {
48
 
  NullS
 
48
  NULL
49
49
};
50
50
 
51
51
const char **ha_blackhole::bas_ext() const
54
54
}
55
55
 
56
56
int ha_blackhole::open(const char *name, int mode __attribute__((unused)),
57
 
                       uint test_if_locked __attribute__((unused)))
 
57
                       uint32_t test_if_locked __attribute__((unused)))
58
58
{
59
59
  if (!(share= get_share(name)))
60
60
    return(HA_ERR_OUT_OF_MEM);
76
76
  return(0);
77
77
}
78
78
 
79
 
const char *ha_blackhole::index_type(uint key_number __attribute__((unused)))
 
79
const char *ha_blackhole::index_type(uint32_t key_number __attribute__((unused)))
80
80
{
81
81
  return("BTREE");
82
82
}
83
83
 
84
 
int ha_blackhole::write_row(uchar * buf __attribute__((unused)))
 
84
int ha_blackhole::write_row(unsigned char * buf __attribute__((unused)))
85
85
{
86
86
  return(table->next_number_field ? update_auto_increment() : 0);
87
87
}
92
92
}
93
93
 
94
94
 
95
 
int ha_blackhole::rnd_next(uchar *buf __attribute__((unused)))
 
95
int ha_blackhole::rnd_next(unsigned char *buf __attribute__((unused)))
96
96
{
97
97
  return(HA_ERR_END_OF_FILE);
98
98
}
99
99
 
100
100
 
101
 
int ha_blackhole::rnd_pos(uchar * buf __attribute__((unused)),
102
 
                          uchar *pos __attribute__((unused)))
 
101
int ha_blackhole::rnd_pos(unsigned char * buf __attribute__((unused)),
 
102
                          unsigned char *pos __attribute__((unused)))
103
103
{
104
104
  assert(0);
105
105
  return(0);
106
106
}
107
107
 
108
108
 
109
 
void ha_blackhole::position(const uchar *record __attribute__((unused)))
 
109
void ha_blackhole::position(const unsigned char *record __attribute__((unused)))
110
110
{
111
111
  assert(0);
112
112
  return;
113
113
}
114
114
 
115
115
 
116
 
int ha_blackhole::info(uint flag)
 
116
int ha_blackhole::info(uint32_t flag)
117
117
{
118
118
  memset(&stats, 0, sizeof(stats));
119
119
  if (flag & HA_STATUS_AUTO)
164
164
}
165
165
 
166
166
 
167
 
int ha_blackhole::index_read_map(uchar * buf __attribute__((unused)),
168
 
                                 const uchar * key __attribute__((unused)),
 
167
int ha_blackhole::index_read_map(unsigned char * buf __attribute__((unused)),
 
168
                                 const unsigned char * key __attribute__((unused)),
169
169
                                 key_part_map keypart_map  __attribute__((unused)),
170
170
                                 enum ha_rkey_function find_flag __attribute__((unused)))
171
171
{
173
173
}
174
174
 
175
175
 
176
 
int ha_blackhole::index_read_idx_map(uchar * buf __attribute__((unused)),
177
 
                                     uint idx __attribute__((unused)),
178
 
                                     const uchar * key __attribute__((unused)),
 
176
int ha_blackhole::index_read_idx_map(unsigned char * buf __attribute__((unused)),
 
177
                                     uint32_t idx __attribute__((unused)),
 
178
                                     const unsigned char * key __attribute__((unused)),
179
179
                                     key_part_map keypart_map __attribute__((unused)),
180
180
                                     enum ha_rkey_function find_flag __attribute__((unused)))
181
181
{
183
183
}
184
184
 
185
185
 
186
 
int ha_blackhole::index_read_last_map(uchar * buf __attribute__((unused)),
187
 
                                      const uchar * key __attribute__((unused)),
 
186
int ha_blackhole::index_read_last_map(unsigned char * buf __attribute__((unused)),
 
187
                                      const unsigned char * key __attribute__((unused)),
188
188
                                      key_part_map keypart_map __attribute__((unused)))
189
189
{
190
190
  return(HA_ERR_END_OF_FILE);
191
191
}
192
192
 
193
193
 
194
 
int ha_blackhole::index_next(uchar * buf __attribute__((unused)))
195
 
{
196
 
  return(HA_ERR_END_OF_FILE);
197
 
}
198
 
 
199
 
 
200
 
int ha_blackhole::index_prev(uchar * buf __attribute__((unused)))
201
 
{
202
 
  return(HA_ERR_END_OF_FILE);
203
 
}
204
 
 
205
 
 
206
 
int ha_blackhole::index_first(uchar * buf __attribute__((unused)))
207
 
{
208
 
  return(HA_ERR_END_OF_FILE);
209
 
}
210
 
 
211
 
 
212
 
int ha_blackhole::index_last(uchar * buf __attribute__((unused)))
 
194
int ha_blackhole::index_next(unsigned char * buf __attribute__((unused)))
 
195
{
 
196
  return(HA_ERR_END_OF_FILE);
 
197
}
 
198
 
 
199
 
 
200
int ha_blackhole::index_prev(unsigned char * buf __attribute__((unused)))
 
201
{
 
202
  return(HA_ERR_END_OF_FILE);
 
203
}
 
204
 
 
205
 
 
206
int ha_blackhole::index_first(unsigned char * buf __attribute__((unused)))
 
207
{
 
208
  return(HA_ERR_END_OF_FILE);
 
209
}
 
210
 
 
211
 
 
212
int ha_blackhole::index_last(unsigned char * buf __attribute__((unused)))
213
213
{
214
214
  return(HA_ERR_END_OF_FILE);
215
215
}
218
218
static st_blackhole_share *get_share(const char *table_name)
219
219
{
220
220
  st_blackhole_share *share;
221
 
  uint length;
 
221
  uint32_t length;
222
222
 
223
223
  length= (uint) strlen(table_name);
224
224
  pthread_mutex_lock(&blackhole_mutex);
225
225
    
226
226
  if (!(share= (st_blackhole_share*) hash_search(&blackhole_open_tables,
227
 
                                                 (uchar*) table_name, length)))
 
227
                                                 (unsigned char*) table_name, length)))
228
228
  {
229
229
    if (!(share= (st_blackhole_share*) my_malloc(sizeof(st_blackhole_share) +
230
230
                                                 length,
232
232
      goto error;
233
233
 
234
234
    share->table_name_length= length;
235
 
    stpcpy(share->table_name, table_name);
 
235
    my_stpcpy(share->table_name, table_name);
236
236
    
237
 
    if (my_hash_insert(&blackhole_open_tables, (uchar*) share))
 
237
    if (my_hash_insert(&blackhole_open_tables, (unsigned char*) share))
238
238
    {
239
 
      my_free((uchar*) share, MYF(0));
 
239
      free((unsigned char*) share);
240
240
      share= NULL;
241
241
      goto error;
242
242
    }
254
254
{
255
255
  pthread_mutex_lock(&blackhole_mutex);
256
256
  if (!--share->use_count)
257
 
    hash_delete(&blackhole_open_tables, (uchar*) share);
 
257
    hash_delete(&blackhole_open_tables, (unsigned char*) share);
258
258
  pthread_mutex_unlock(&blackhole_mutex);
259
259
}
260
260
 
261
261
static void blackhole_free_key(st_blackhole_share *share)
262
262
{
263
263
  thr_lock_delete(&share->lock);
264
 
  my_free((uchar*) share, MYF(0));
 
264
  free((unsigned char*) share);
265
265
}
266
266
 
267
 
static uchar* blackhole_get_key(st_blackhole_share *share, size_t *length,
 
267
static unsigned char* blackhole_get_key(st_blackhole_share *share, size_t *length,
268
268
                                bool not_used __attribute__((unused)))
269
269
{
270
270
  *length= share->table_name_length;
271
 
  return (uchar*) share->table_name;
 
271
  return (unsigned char*) share->table_name;
272
272
}
273
273
 
274
274
static int blackhole_init(void *p)
276
276
  handlerton *blackhole_hton;
277
277
  blackhole_hton= (handlerton *)p;
278
278
  blackhole_hton->state= SHOW_OPTION_YES;
279
 
  blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB;
280
279
  blackhole_hton->create= blackhole_create_handler;
281
280
  blackhole_hton->flags= HTON_CAN_RECREATE;
282
281
  
283
 
  VOID(pthread_mutex_init(&blackhole_mutex, MY_MUTEX_INIT_FAST));
 
282
  pthread_mutex_init(&blackhole_mutex, MY_MUTEX_INIT_FAST);
284
283
  (void) hash_init(&blackhole_open_tables, system_charset_info,32,0,0,
285
284
                   (hash_get_key) blackhole_get_key,
286
285
                   (hash_free_key) blackhole_free_key, 0);