~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2009-11-18 06:24:48 UTC
  • mfrom: (1220.1.15 staging)
  • Revision ID: brian@gaz-20091118062448-o36lo3yv81sc6u9z
Merge Brian + Stewart

Show diffs side-by-side

added added

removed removed

Lines of Context:
1276
1276
      key_info->comment.str= key->key_create_info.comment.str;
1277
1277
    }
1278
1278
 
 
1279
    message::Table::Field *protofield= NULL;
 
1280
 
1279
1281
    List_iterator<Key_part_spec> cols(key->columns), cols2(key->columns);
1280
1282
    for (uint32_t column_nr=0 ; (column=cols++) ; column_nr++)
1281
1283
    {
1282
1284
      uint32_t length;
1283
1285
      Key_part_spec *dup_column;
 
1286
      int proto_field_nr= 0;
1284
1287
 
1285
1288
      it.rewind();
1286
1289
      field=0;
1287
 
      while ((sql_field=it++) &&
 
1290
      while ((sql_field=it++) && ++proto_field_nr &&
1288
1291
             my_strcasecmp(system_charset_info,
1289
1292
                           column->field_name.str,
1290
1293
                           sql_field->field_name))
1306
1309
        }
1307
1310
      }
1308
1311
      cols2.rewind();
 
1312
 
 
1313
      if (create_proto->field_size() > 0)
 
1314
        protofield= create_proto->mutable_field(proto_field_nr - 1);
 
1315
 
1309
1316
      {
1310
1317
        column->length*= sql_field->charset->mbmaxlen;
1311
1318
 
1329
1336
            /* Implicitly set primary key fields to NOT NULL for ISO conf. */
1330
1337
            sql_field->flags|= NOT_NULL_FLAG;
1331
1338
            null_fields--;
 
1339
 
 
1340
            if (protofield)
 
1341
            {
 
1342
              message::Table::Field::FieldConstraints *constraints;
 
1343
              constraints= protofield->mutable_constraints();
 
1344
              constraints->set_is_nullable(false);
 
1345
            }
 
1346
 
1332
1347
          }
1333
1348
          else
1334
1349
          {
2447
2462
 
2448
2463
    if (src_table->schema_table)
2449
2464
    {
 
2465
      /* 
 
2466
        If engine was not specified and we are reading from the I_S, then we need to 
 
2467
        toss an error. This should go away later on when we straighten out the 
 
2468
        I_S engine.
 
2469
      */
 
2470
      if (! (create_info->used_fields & HA_CREATE_USED_ENGINE))
 
2471
      {
 
2472
        pthread_mutex_unlock(&LOCK_open);
 
2473
        my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
 
2474
                 "INFORMATION_ENGINE",
 
2475
                 "TEMPORARY");
 
2476
        goto err;
 
2477
      }
 
2478
 
2450
2479
      if (create_like_schema_frm(session, src_table, create_info, &src_proto))
2451
2480
      {
2452
2481
        pthread_mutex_unlock(&LOCK_open);
2473
2502
      protoengine->set_name(create_table_proto.engine().name());
2474
2503
    }
2475
2504
 
2476
 
    string dst_proto_path(dst_path);
2477
 
    string file_ext = ".dfe";
2478
 
 
2479
 
    dst_proto_path.append(file_ext);
2480
 
 
2481
2505
    if (protoerr == EEXIST)
2482
2506
    {
2483
2507
      plugin::StorageEngine* engine= plugin::StorageEngine::findByName(*session,
2484
2508
                                                                       new_proto.engine().name());
2485
2509
 
2486
2510
      if (engine->check_flag(HTON_BIT_HAS_DATA_DICTIONARY) == false)
 
2511
      {
 
2512
        string dst_proto_path(dst_path);
 
2513
        dst_proto_path.append(".dfe");
 
2514
 
2487
2515
        protoerr= drizzle_write_proto_file(dst_proto_path.c_str(), &new_proto);
 
2516
      }
2488
2517
      else
 
2518
      {
2489
2519
        protoerr= 0;
 
2520
      }
2490
2521
    }
2491
2522
 
2492
2523
    if (protoerr)