~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

Added code necessary for building plugins dynamically.
Merged in changes from lifeless to allow autoreconf to work.
Touching plugin.ini files now triggers a rebuid - so config/autorun.sh is no
longer required to be run after touching those.
Removed the duplicate plugin names - also removed the issue that getting them
different would silently fail weirdly later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
340
340
  string built_query;
341
341
 
342
342
  if (if_exists)
343
 
    built_query.append("DROP Table IF EXISTS ");
 
343
    built_query.append("DROP TABLE IF EXISTS ");
344
344
  else
345
 
    built_query.append("DROP Table ");
 
345
    built_query.append("DROP TABLE ");
346
346
 
347
347
  built_query.append("`");
348
348
  if (session->db == NULL || strcmp(db_name ,session->db) != 0)
524
524
 
525
525
    if (drop_temporary ||
526
526
        ((table_type == NULL
527
 
          && (plugin::StorageEngine::getTableProto(path, NULL) != EEXIST))))
 
527
          && (plugin::StorageEngine::getTableDefinition(*session, 
 
528
                                                        path, 
 
529
                                                        db, 
 
530
                                                        table->table_name, 
 
531
                                                        table->internal_tmp_table) != EEXIST))))
528
532
    {
529
533
      // Table was not found on disk and table can't be created from engine
530
534
      if (if_exists)
536
540
    }
537
541
    else
538
542
    {
539
 
      error= plugin::StorageEngine::deleteTable(session, path, db,
 
543
      error= plugin::StorageEngine::dropTable(*session, path, db,
540
544
                                                table->table_name,
541
545
                                                ! dont_log_query);
542
546
      if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) && if_exists)
605
609
    != 0        Error
606
610
*/
607
611
 
608
 
bool quick_rm_table(plugin::StorageEngine *, const char *db,
 
612
bool quick_rm_table(Session& session, const char *db,
609
613
                    const char *table_name, bool is_tmp)
610
614
{
611
615
  char path[FN_REFLEN];
613
617
 
614
618
  build_table_filename(path, sizeof(path), db, table_name, is_tmp);
615
619
 
616
 
  return (plugin::StorageEngine::deleteTable(current_session, path, db,
617
 
                                             table_name, 0)
 
620
  return (plugin::StorageEngine::dropTable(session, path, db,
 
621
                                           table_name, 0)
618
622
          || error);
619
623
}
620
624
 
828
832
 
829
833
int mysql_prepare_create_table(Session *session,
830
834
                               HA_CREATE_INFO *create_info,
 
835
                               message::Table *create_proto,
831
836
                               AlterInfo *alter_info,
832
837
                               bool tmp_table,
833
838
                               uint32_t *db_options,
1245
1250
    */
1246
1251
    key_info->block_size= (key->key_create_info.block_size ?
1247
1252
                           key->key_create_info.block_size :
1248
 
                           create_info->key_block_size);
 
1253
                           create_proto->options().key_block_size());
1249
1254
 
1250
1255
    if (key_info->block_size)
1251
1256
      key_info->flags|= HA_USES_BLOCK_SIZE;
1620
1625
 
1621
1626
  set_table_default_charset(create_info, (char*) db);
1622
1627
 
1623
 
  if (mysql_prepare_create_table(session, create_info, alter_info,
 
1628
  if (mysql_prepare_create_table(session, create_info, table_proto, alter_info,
1624
1629
                                 internal_tmp_table,
1625
1630
                                 &db_options, file,
1626
1631
                                 &key_info_buffer, &key_count,
1665
1670
  pthread_mutex_lock(&LOCK_open); /* CREATE TABLE (some confussion on naming, double check) */
1666
1671
  if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
1667
1672
  {
1668
 
    if (plugin::StorageEngine::getTableProto(path, NULL)==EEXIST)
 
1673
    if (plugin::StorageEngine::getTableDefinition(*session, path, db, table_name, internal_tmp_table)==EEXIST)
1669
1674
    {
1670
1675
      if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
1671
1676
      {
1715
1720
    table_path_length= build_table_filename(table_path, sizeof(table_path),
1716
1721
                                            db, table_name, false);
1717
1722
 
1718
 
    int retcode= plugin::StorageEngine::getTableProto(table_path, NULL);
 
1723
    int retcode= plugin::StorageEngine::getTableDefinition(*session, table_path, db, table_name, false);
1719
1724
    switch (retcode)
1720
1725
    {
1721
1726
      case ENOENT:
1922
1927
  build_table_filename(to, sizeof(to), new_db, new_name,
1923
1928
                       flags & FN_TO_IS_TMP);
1924
1929
 
1925
 
  if (!(error=base->renameTable(session, from_base, to_base)))
 
1930
  if (!(error= base->renameTable(session, from_base, to_base)))
1926
1931
  {
1927
1932
    if(!(flags & NO_FRM_RENAME)
1928
1933
       && base->check_flag(HTON_BIT_HAS_DATA_DICTIONARY) == 0
2415
2420
      goto table_exists;
2416
2421
    dst_path_length= build_table_filename(dst_path, sizeof(dst_path),
2417
2422
                                          db, table_name, false);
2418
 
    if (plugin::StorageEngine::getTableProto(dst_path, NULL) == EEXIST)
 
2423
    if (plugin::StorageEngine::getTableDefinition(*session, dst_path, db, table_name, false) == EEXIST)
2419
2424
      goto table_exists;
2420
2425
  }
2421
2426
 
2448
2453
    }
2449
2454
    else
2450
2455
    {
2451
 
      protoerr= plugin::StorageEngine::getTableProto(src_path, &src_proto);
 
2456
      protoerr= plugin::StorageEngine::getTableDefinition(*session,
 
2457
                                                          src_path,
 
2458
                                                          db,
 
2459
                                                          table_name,
 
2460
                                                          false,
 
2461
                                                          &src_proto);
2452
2462
    }
2453
2463
 
2454
2464
    message::Table new_proto(src_proto);
2468
2478
 
2469
2479
    if (protoerr == EEXIST)
2470
2480
    {
2471
 
      plugin::StorageEngine* engine= plugin::StorageEngine::findByName(session,
 
2481
      plugin::StorageEngine* engine= plugin::StorageEngine::findByName(*session,
2472
2482
                                                                       new_proto.engine().name());
2473
2483
 
2474
2484
      if (engine->check_flag(HTON_BIT_HAS_DATA_DICTIONARY) == false)
2492
2502
      creation, instead create the table directly (for both normal
2493
2503
      and temporary tables).
2494
2504
    */
2495
 
    err= plugin::StorageEngine::createTable(session, dst_path, db, table_name, create_info, 
2496
 
                                            true, &new_proto);
 
2505
    err= plugin::StorageEngine::createTable(*session, dst_path, db, table_name, *create_info, 
 
2506
                                            true, new_proto);
2497
2507
  }
2498
2508
  pthread_mutex_unlock(&LOCK_open);
2499
2509
 
2507
2517
  }
2508
2518
  else if (err)
2509
2519
  {
2510
 
    (void) quick_rm_table(create_info->db_type, db,
 
2520
    (void) quick_rm_table(*session, db,
2511
2521
                          table_name, false);
2512
2522
    goto err;
2513
2523
  }