~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2010-11-28 20:44:02 UTC
  • mfrom: (1954.2.4 alter-table)
  • Revision ID: brian@tangent.org-20101128204402-e6ab9fucshilci81
Merge in table identifier work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
270
270
  return error;
271
271
}
272
272
 
273
 
 
274
 
/*
275
 
  Quickly remove a table.
276
 
 
277
 
  SYNOPSIS
278
 
    quick_rm_table()
279
 
      base                      The plugin::StorageEngine handle.
280
 
      db                        The database name.
281
 
      table_name                The table name.
282
 
      is_tmp                    If the table is temp.
283
 
 
284
 
  RETURN
285
 
    0           OK
286
 
    != 0        Error
287
 
*/
288
 
bool quick_rm_table(Session& session,
289
 
                    TableIdentifier &identifier)
290
 
{
291
 
  return (plugin::StorageEngine::dropTable(session, identifier));
292
 
}
293
 
 
294
273
/*
295
274
  Sort keys in the following order:
296
275
  - PRIMARY KEY
1284
1263
}
1285
1264
 
1286
1265
static bool locked_create_event(Session *session,
1287
 
                                TableIdentifier &identifier,
 
1266
                                const TableIdentifier &identifier,
1288
1267
                                HA_CREATE_INFO *create_info,
1289
1268
                                message::Table &table_proto,
1290
1269
                                AlterInfo *alter_info,
1319
1298
        return error;
1320
1299
      }
1321
1300
 
1322
 
      my_error(ER_TABLE_EXISTS_ERROR, MYF(0), identifier.getSQLPath().c_str());
 
1301
      std::string path;
 
1302
      identifier.getSQLPath(path);
 
1303
      my_error(ER_TABLE_EXISTS_ERROR, MYF(0), path.c_str());
 
1304
 
1323
1305
      return error;
1324
1306
    }
1325
1307
 
1338
1320
      */
1339
1321
      if (definition::Cache::singleton().find(identifier.getKey()))
1340
1322
      {
1341
 
        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), identifier.getSQLPath().c_str());
 
1323
        std::string path;
 
1324
        identifier.getSQLPath(path);
 
1325
        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), path.c_str());
 
1326
 
1342
1327
        return error;
1343
1328
      }
1344
1329
    }
1414
1399
*/
1415
1400
 
1416
1401
bool mysql_create_table_no_lock(Session *session,
1417
 
                                TableIdentifier &identifier,
 
1402
                                const TableIdentifier &identifier,
1418
1403
                                HA_CREATE_INFO *create_info,
1419
1404
                                message::Table &table_proto,
1420
1405
                                AlterInfo *alter_info,
1466
1451
  @note the following two methods implement create [temporary] table.
1467
1452
*/
1468
1453
static bool drizzle_create_table(Session *session,
1469
 
                                 TableIdentifier &identifier,
 
1454
                                 const TableIdentifier &identifier,
1470
1455
                                 HA_CREATE_INFO *create_info,
1471
1456
                                 message::Table &table_proto,
1472
1457
                                 AlterInfo *alter_info,
1493
1478
    }
1494
1479
    else
1495
1480
    {
1496
 
      my_error(ER_TABLE_EXISTS_ERROR, MYF(0), identifier.getSQLPath().c_str());
 
1481
      std::string path;
 
1482
      identifier.getSQLPath(path);
 
1483
      my_error(ER_TABLE_EXISTS_ERROR, MYF(0), path.c_str());
1497
1484
      result= true;
1498
1485
    }
1499
1486
  }
1523
1510
  Database locking aware wrapper for mysql_create_table_no_lock(),
1524
1511
*/
1525
1512
bool mysql_create_table(Session *session,
1526
 
                        TableIdentifier &identifier,
 
1513
                        const TableIdentifier &identifier,
1527
1514
                        HA_CREATE_INFO *create_info,
1528
1515
                        message::Table &table_proto,
1529
1516
                        AlterInfo *alter_info,
1619
1606
bool
1620
1607
mysql_rename_table(Session &session,
1621
1608
                   plugin::StorageEngine *base,
1622
 
                   TableIdentifier &from,
1623
 
                   TableIdentifier &to)
 
1609
                   const TableIdentifier &from,
 
1610
                   const TableIdentifier &to)
1624
1611
{
1625
1612
  int error= 0;
1626
1613
 
1640
1627
  }
1641
1628
  else if (error)
1642
1629
  {
1643
 
    const char *from_identifier= from.isTmp() ? "#sql-temporary" : from.getSQLPath().c_str();
1644
 
    const char *to_identifier= to.isTmp() ? "#sql-temporary" : to.getSQLPath().c_str();
 
1630
    std::string from_path;
 
1631
    std::string to_path;
 
1632
 
 
1633
    from.getSQLPath(from_path);
 
1634
    to.getSQLPath(to_path);
 
1635
 
 
1636
    const char *from_identifier= from.isTmp() ? "#sql-temporary" : from_path.c_str();
 
1637
    const char *to_identifier= to.isTmp() ? "#sql-temporary" : to_path.c_str();
1645
1638
 
1646
1639
    my_error(ER_ERROR_ON_RENAME, MYF(0), from_identifier, to_identifier, error);
1647
1640
  }
1974
1967
    See bug #28614 for more info.
1975
1968
  */
1976
1969
static bool create_table_wrapper(Session &session, const message::Table& create_table_proto,
1977
 
                                 TableIdentifier &destination_identifier,
1978
 
                                 TableIdentifier &src_table,
 
1970
                                 const TableIdentifier &destination_identifier,
 
1971
                                 const TableIdentifier &src_table,
1979
1972
                                 bool is_engine_set)
1980
1973
{
1981
1974
  int protoerr= EEXIST;
2051
2044
*/
2052
2045
 
2053
2046
bool mysql_create_like_table(Session* session,
2054
 
                             TableIdentifier &destination_identifier,
 
2047
                             const TableIdentifier &destination_identifier,
2055
2048
                             TableList* table, TableList* src_table,
2056
2049
                             message::Table &create_table_proto,
2057
2050
                             bool is_if_not_exists,
2145
2138
      // anything that might have been created (read... it is a hack)
2146
2139
      if (not was_created)
2147
2140
      {
2148
 
        quick_rm_table(*session, destination_identifier);
 
2141
        plugin::StorageEngine::dropTable(*session, destination_identifier);
2149
2142
      } 
2150
2143
      else
2151
2144
      {