~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/handler/ha_innodb.cc

Fix innodb to just directly use the identifier (this way we only need to
modify one code path).

Show diffs side-by-side

added added

removed removed

Lines of Context:
3351
3351
                    uint    test_if_locked) /*!< in: not used */
3352
3352
{
3353
3353
  dict_table_t* ib_table;
3354
 
  char    norm_name[FN_REFLEN];
3355
3354
  Session*    session;
3356
3355
 
3357
3356
  UT_NOT_USED(mode);
3366
3365
    getTransactionalEngine()->releaseTemporaryLatches(session);
3367
3366
  }
3368
3367
 
3369
 
  normalize_table_name(norm_name, identifier.getPath().c_str());
3370
 
 
3371
3368
  user_session = NULL;
3372
3369
 
3373
 
  if (!(share=get_share(identifier.getPath().c_str()))) {
 
3370
  if (!(share=get_share(identifier.getKeyPath().c_str()))) {
3374
3371
 
3375
3372
    return(1);
3376
3373
  }
3399
3396
  }
3400
3397
 
3401
3398
  /* Get pointer to a table object in InnoDB dictionary cache */
3402
 
  ib_table = dict_table_get(norm_name, TRUE);
 
3399
  ib_table = dict_table_get(identifier.getKeyPath().c_str(), TRUE);
3403
3400
  
3404
3401
  if (NULL == ib_table) {
3405
3402
    errmsg_printf(error::ERROR, "Cannot find or open table %s from\n"
3416
3413
        "doesn't support.\n"
3417
3414
        "See " REFMAN "innodb-troubleshooting.html\n"
3418
3415
        "how you can resolve the problem.\n",
3419
 
        norm_name);
 
3416
        identifier.getKeyPath().c_str());
3420
3417
    free_share(share);
3421
3418
    upd_buff.resize(0);
3422
3419
    key_val_buff.resize(0);
3433
3430
        "or have you used DISCARD TABLESPACE?\n"
3434
3431
        "See " REFMAN "innodb-troubleshooting.html\n"
3435
3432
        "how you can resolve the problem.\n",
3436
 
        norm_name);
 
3433
        identifier.getKeyPath().c_str());
3437
3434
    free_share(share);
3438
3435
    upd_buff.resize(0);
3439
3436
    key_val_buff.resize(0);
3456
3453
 
3457
3454
  if (!innobase_build_index_translation(getTable(), ib_table, share)) {
3458
3455
    errmsg_printf(error::ERROR, "Build InnoDB index translation table for"
3459
 
                    " Table %s failed", identifier.getPath().c_str());
 
3456
                    " Table %s failed", identifier.getKeyPath().c_str());
3460
3457
  }
3461
3458
 
3462
3459
  /* Allocate a buffer for a 'row reference'. A row reference is
6129
6126
  trx_t*    trx;
6130
6127
  int   primary_key_no;
6131
6128
  uint    i;
6132
 
  char    name2[FN_REFLEN];
6133
 
  char    norm_name[FN_REFLEN];
6134
6129
  ib_int64_t  auto_inc_value;
6135
6130
  ulint   iflags;
6136
6131
  /* Cache the value of innodb_file_format, in case it is
6140
6135
  const char* stmt;
6141
6136
  size_t stmt_len;
6142
6137
 
6143
 
  const char *table_name= identifier.getPath().c_str();
6144
 
 
6145
6138
  if (form.getShare()->sizeFields() > 1000) {
6146
6139
    /* The limit probably should be REC_MAX_N_FIELDS - 3 = 1020,
6147
6140
      but we play safe here */
6163
6156
 
6164
6157
  srv_lower_case_table_names = TRUE;
6165
6158
 
6166
 
  strcpy(name2, table_name);
6167
 
 
6168
 
  normalize_table_name(norm_name, name2);
6169
 
 
6170
6159
  /* Latch the InnoDB data dictionary exclusively so that no deadlocks
6171
6160
    or lock waits can happen in it during a table create operation.
6172
6161
    Drop table etc. do this latching in row0mysql.c. */
6274
6263
  if (lex_identified_temp_table)
6275
6264
    iflags |= DICT_TF2_TEMPORARY << DICT_TF2_SHIFT;
6276
6265
 
6277
 
  error= create_table_def(trx, &form, norm_name,
6278
 
                          lex_identified_temp_table ? name2 : NULL,
 
6266
  error= create_table_def(trx, &form, identifier.getKeyPath().c_str(),
 
6267
                          lex_identified_temp_table ? identifier.getKeyPath().c_str() : NULL,
6279
6268
                          iflags);
6280
6269
 
6281
6270
  session.setXaId(trx->id);
6291
6280
      order the rows by their row id which is internally generated
6292
6281
      by InnoDB */
6293
6282
 
6294
 
    error = create_clustered_index_when_no_primary(trx, iflags, norm_name);
 
6283
    error = create_clustered_index_when_no_primary(trx, iflags, identifier.getKeyPath().c_str());
6295
6284
    if (error) {
6296
6285
      goto cleanup;
6297
6286
    }
6299
6288
 
6300
6289
  if (primary_key_no != -1) {
6301
6290
    /* In InnoDB the clustered index must always be created first */
6302
 
    if ((error = create_index(trx, &form, iflags, norm_name,
 
6291
    if ((error = create_index(trx, &form, iflags, identifier.getKeyPath().c_str(),
6303
6292
                              (uint) primary_key_no))) {
6304
6293
      goto cleanup;
6305
6294
    }
6308
6297
  for (i = 0; i < form.getShare()->sizeKeys(); i++) {
6309
6298
    if (i != (uint) primary_key_no) {
6310
6299
 
6311
 
      if ((error = create_index(trx, &form, iflags, norm_name,
 
6300
      if ((error = create_index(trx, &form, iflags, identifier.getKeyPath().c_str(),
6312
6301
                                i))) {
6313
6302
        goto cleanup;
6314
6303
      }
6331
6320
 
6332
6321
    error = row_table_add_foreign_constraints(trx,
6333
6322
                                              query, strlen(query),
6334
 
                                              norm_name,
 
6323
                                              identifier.getKeyPath().c_str(),
6335
6324
                                              lex_identified_temp_table);
6336
6325
    switch (error) {
6337
6326
 
6342
6331
                          "Create table '%s' with foreign key constraint"
6343
6332
                          " failed. There is no index in the referenced"
6344
6333
                          " table where the referenced columns appear"
6345
 
                          " as the first columns.\n", norm_name);
 
6334
                          " as the first columns.\n", identifier.getKeyPath().c_str());
6346
6335
      break;
6347
6336
 
6348
6337
    case DB_CHILD_NO_INDEX:
6352
6341
                          "Create table '%s' with foreign key constraint"
6353
6342
                          " failed. There is no index in the referencing"
6354
6343
                          " table where referencing columns appear"
6355
 
                          " as the first columns.\n", norm_name);
 
6344
                          " as the first columns.\n", identifier.getKeyPath().c_str());
6356
6345
      break;
6357
6346
    }
6358
6347
 
6373
6362
 
6374
6363
  log_buffer_flush_to_disk();
6375
6364
 
6376
 
  innobase_table = dict_table_get(norm_name, FALSE);
 
6365
  innobase_table = dict_table_get(identifier.getKeyPath().c_str(), FALSE);
6377
6366
 
6378
6367
  assert(innobase_table != 0);
6379
6368
 
6529
6518
  int error;
6530
6519
  trx_t*  parent_trx;
6531
6520
  trx_t*  trx;
6532
 
  char  norm_name[1000];
6533
6521
 
6534
6522
  ut_a(identifier.getPath().length() < 1000);
6535
6523
 
6536
 
  /* Strangely, MySQL passes the table name without the '.frm'
6537
 
    extension, in contrast to ::create */
6538
 
  normalize_table_name(norm_name, identifier.getPath().c_str());
6539
 
 
6540
6524
  /* Get the transaction associated with the current session, or create one
6541
6525
    if not yet created */
6542
6526
 
6553
6537
 
6554
6538
  /* Drop the table in InnoDB */
6555
6539
 
6556
 
  error = row_drop_table_for_mysql(norm_name, trx,
 
6540
  error = row_drop_table_for_mysql(identifier.getKeyPath().c_str(), trx,
6557
6541
                                   session_sql_command(&session)
6558
6542
                                   == SQLCOM_DROP_DB);
6559
6543