~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Brian Aker
  • Date: 2009-07-11 19:23:04 UTC
  • mfrom: (1089.1.14 merge)
  • Revision ID: brian@gaz-20090711192304-ootijyl5yf9jq9kd
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
 
198
198
  if (!(share= alloc_table_share(table_list, key, key_length)))
199
199
  {
200
 
    return 0;
 
200
    return NULL;
201
201
  }
202
202
 
203
203
  /*
209
209
  if (my_hash_insert(&table_def_cache, (unsigned char*) share))
210
210
  {
211
211
    share->free_table_share();
212
 
    return 0;                           // return error
 
212
    return NULL;                                // return error
213
213
  }
214
214
  if (open_table_def(session, share))
215
215
  {
216
216
    *error= share->error;
217
217
    (void) hash_delete(&table_def_cache, (unsigned char*) share);
218
 
    return 0;
 
218
    return NULL;
219
219
  }
220
220
  share->ref_count++;                           // Mark in use
221
221
  (void) pthread_mutex_unlock(&share->mutex);
235
235
    share->open_table_error(share->error, share->open_errno, share->errarg);
236
236
    (void) pthread_mutex_unlock(&share->mutex);
237
237
 
238
 
    return 0;
 
238
    return NULL;
239
239
  }
240
240
 
241
241
  share->ref_count++;
242
242
  (void) pthread_mutex_unlock(&share->mutex);
243
243
 
244
 
  return(share);
245
 
}
246
 
 
247
 
 
248
 
/*
249
 
  Get a table share. If it didn't exist, try creating it from engine
250
 
 
251
 
  For arguments and return values, see get_table_from_share()
252
 
*/
253
 
 
254
 
static TableShare
255
 
*get_table_share_with_create(Session *session, TableList *table_list,
256
 
                             char *key, uint32_t key_length,
257
 
                             uint32_t db_flags, int *error)
258
 
{
259
 
  TableShare *share;
260
 
 
261
 
  share= get_table_share(session, table_list, key, key_length, db_flags, error);
262
 
  /*
263
 
    If share is not NULL, we found an existing share.
264
 
 
265
 
    If share is NULL, and there is no error, we're inside
266
 
    pre-locking, which silences 'ER_NO_SUCH_TABLE' errors
267
 
    with the intention to silently drop non-existing tables
268
 
    from the pre-locking list. In this case we still need to try
269
 
    auto-discover before returning a NULL share.
270
 
 
271
 
    If share is NULL and the error is ER_NO_SUCH_TABLE, this is
272
 
    the same as above, only that the error was not silenced by
273
 
    pre-locking. Once again, we need to try to auto-discover
274
 
    the share.
275
 
 
276
 
    Finally, if share is still NULL, it's a real error and we need
277
 
    to abort.
278
 
 
279
 
    @todo Rework alternative ways to deal with ER_NO_SUCH Table.
280
 
  */
281
 
  if (share || (session->is_error() && (session->main_da.sql_errno() != ER_NO_SUCH_TABLE)))
282
 
 
283
 
    return(share);
284
 
 
285
 
  return 0;
 
244
  return share;
286
245
}
287
246
 
288
247
 
2320
2279
 
2321
2280
  safe_mutex_assert_owner(&LOCK_open);
2322
2281
retry:
2323
 
  if (!(share= get_table_share_with_create(session, table_list, cache_key,
 
2282
  if (!(share= get_table_share(session, table_list, cache_key,
2324
2283
                                           cache_key_length,
2325
2284
                                           table_list->i_s_requested_object,
2326
2285
                                           &error)))