~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Brian Aker
  • Date: 2011-01-17 23:44:48 UTC
  • mfrom: (2088.1.5 drizzle-build)
  • Revision ID: brian@tangent.org-20110117234448-0tt6rd6fxa3csdaf
Rollup of all changes for identifier/error

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
    This has to be done to ensure that the table share is removed from
111
111
    the table defintion cache as soon as the last instance is removed
112
112
  */
113
 
  TableIdentifier identifier(table->getShare()->getSchemaName(), table->getShare()->getTableName(), message::Table::INTERNAL);
114
 
  const TableIdentifier::Key &key(identifier.getKey());
 
113
  identifier::Table identifier(table->getShare()->getSchemaName(), table->getShare()->getTableName(), message::Table::INTERNAL);
 
114
  const identifier::Table::Key &key(identifier.getKey());
115
115
  TableShare *share= new TableShare(identifier.getType(),
116
116
                                    identifier,
117
117
                                    const_cast<char *>(key.vector()),  static_cast<uint32_t>(table->getShare()->getCacheKeySize()));
233
233
      bool found= false;
234
234
      for (TableList *table= tables; table; table= table->next_local)
235
235
      {
236
 
        TableIdentifier identifier(table->getSchemaName(), table->getTableName());
 
236
        identifier::Table identifier(table->getSchemaName(), table->getTableName());
237
237
        if (table::Cache::singleton().removeTable(session, identifier,
238
238
                                    RTFC_OWNED_BY_Session_FLAG))
239
239
        {
517
517
}
518
518
 
519
519
 
520
 
void Open_tables_state::doGetTableNames(const SchemaIdentifier &schema_identifier,
 
520
void Open_tables_state::doGetTableNames(const identifier::Schema &schema_identifier,
521
521
                                        std::set<std::string>& set_of_names)
522
522
{
523
523
  for (Table *table= getTemporaryTables() ; table ; table= table->getNext())
530
530
}
531
531
 
532
532
void Open_tables_state::doGetTableNames(CachedDirectory &,
533
 
                                        const SchemaIdentifier &schema_identifier,
 
533
                                        const identifier::Schema &schema_identifier,
534
534
                                        std::set<std::string> &set_of_names)
535
535
{
536
536
  doGetTableNames(schema_identifier, set_of_names);
537
537
}
538
538
 
539
 
void Open_tables_state::doGetTableIdentifiers(const SchemaIdentifier &schema_identifier,
540
 
                                              TableIdentifier::vector &set_of_identifiers)
 
539
void Open_tables_state::doGetTableIdentifiers(const identifier::Schema &schema_identifier,
 
540
                                              identifier::Table::vector &set_of_identifiers)
541
541
{
542
542
  for (Table *table= getTemporaryTables() ; table ; table= table->getNext())
543
543
  {
544
544
    if (schema_identifier.compare(table->getShare()->getSchemaName()))
545
545
    {
546
 
      set_of_identifiers.push_back(TableIdentifier(table->getShare()->getSchemaName(),
 
546
      set_of_identifiers.push_back(identifier::Table(table->getShare()->getSchemaName(),
547
547
                                                   table->getShare()->getTableName(),
548
548
                                                   table->getShare()->getPath()));
549
549
    }
551
551
}
552
552
 
553
553
void Open_tables_state::doGetTableIdentifiers(CachedDirectory &,
554
 
                                              const SchemaIdentifier &schema_identifier,
555
 
                                              TableIdentifier::vector &set_of_identifiers)
 
554
                                              const identifier::Schema &schema_identifier,
 
555
                                              identifier::Table::vector &set_of_identifiers)
556
556
{
557
557
  doGetTableIdentifiers(schema_identifier, set_of_identifiers);
558
558
}
559
559
 
560
 
bool Open_tables_state::doDoesTableExist(const TableIdentifier &identifier)
 
560
bool Open_tables_state::doDoesTableExist(const identifier::Table &identifier)
561
561
{
562
562
  for (Table *table= getTemporaryTables() ; table ; table= table->getNext())
563
563
  {
573
573
  return false;
574
574
}
575
575
 
576
 
int Open_tables_state::doGetTableDefinition(const TableIdentifier &identifier,
 
576
int Open_tables_state::doGetTableDefinition(const identifier::Table &identifier,
577
577
                                  message::Table &table_proto)
578
578
{
579
579
  for (Table *table= getTemporaryTables() ; table ; table= table->getNext())
592
592
  return ENOENT;
593
593
}
594
594
 
595
 
Table *Open_tables_state::find_temporary_table(const TableIdentifier &identifier)
 
595
Table *Open_tables_state::find_temporary_table(const identifier::Table &identifier)
596
596
{
597
597
  for (Table *table= temporary_tables ; table ; table= table->getNext())
598
598
  {
630
630
  @retval -1  the table is in use by a outer query
631
631
*/
632
632
 
633
 
int Open_tables_state::drop_temporary_table(const drizzled::TableIdentifier &identifier)
 
633
int Open_tables_state::drop_temporary_table(const drizzled::identifier::Table &identifier)
634
634
{
635
635
  Table *table;
636
636
 
662
662
 
663
663
void Session::unlink_open_table(Table *find)
664
664
{
665
 
  const TableIdentifier::Key find_key(find->getShare()->getCacheKey());
 
665
  const identifier::Table::Key find_key(find->getShare()->getCacheKey());
666
666
  Table **prev;
667
667
  safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
668
668
 
716
716
  table that was locked with LOCK TABLES.
717
717
*/
718
718
 
719
 
void Session::drop_open_table(Table *table, const TableIdentifier &identifier)
 
719
void Session::drop_open_table(Table *table, const identifier::Table &identifier)
720
720
{
721
721
  if (table->getShare()->getType())
722
722
  {
791
791
  case of failure.
792
792
*/
793
793
 
794
 
table::Placeholder *Session::table_cache_insert_placeholder(const drizzled::TableIdentifier &arg)
 
794
table::Placeholder *Session::table_cache_insert_placeholder(const drizzled::identifier::Table &arg)
795
795
{
796
796
  safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
797
797
 
798
798
  /*
799
799
    Create a table entry with the right key and with an old refresh version
800
800
  */
801
 
  TableIdentifier identifier(arg.getSchemaName(), arg.getTableName(), message::Table::INTERNAL);
 
801
  identifier::Table identifier(arg.getSchemaName(), arg.getTableName(), message::Table::INTERNAL);
802
802
  table::Placeholder *table= new table::Placeholder(this, identifier);
803
803
 
804
804
  if (not table::Cache::singleton().insert(table))
833
833
  @retval  true   Error occured (OOM)
834
834
  @retval  false  Success. 'table' parameter set according to above rules.
835
835
*/
836
 
bool Session::lock_table_name_if_not_cached(const TableIdentifier &identifier, Table **table)
 
836
bool Session::lock_table_name_if_not_cached(const identifier::Table &identifier, Table **table)
837
837
{
838
 
  const TableIdentifier::Key &key(identifier.getKey());
 
838
  const identifier::Table::Key &key(identifier.getKey());
839
839
 
840
840
  boost_unique_lock_t scope_lock(table::Cache::singleton().mutex()); /* Obtain a name lock even though table is not in cache (like for create table)  */
841
841
 
912
912
  if (getKilled())
913
913
    return NULL;
914
914
 
915
 
  TableIdentifier identifier(table_list->getSchemaName(), table_list->getTableName());
916
 
  const TableIdentifier::Key &key(identifier.getKey());
 
915
  identifier::Table identifier(table_list->getSchemaName(), table_list->getTableName());
 
916
  const identifier::Table::Key &key(identifier.getKey());
917
917
  table::CacheRange ppp;
918
918
 
919
919
  /*
1115
1115
 
1116
1116
        if (table_list->isCreate())
1117
1117
        {
1118
 
          TableIdentifier  lock_table_identifier(table_list->getSchemaName(), table_list->getTableName(), message::Table::STANDARD);
 
1118
          identifier::Table  lock_table_identifier(table_list->getSchemaName(), table_list->getTableName(), message::Table::STANDARD);
1119
1119
 
1120
1120
          if (not plugin::StorageEngine::doesTableExist(*this, lock_table_identifier))
1121
1121
          {
1222
1222
  the strings are used in a loop even after the share may be freed.
1223
1223
*/
1224
1224
 
1225
 
void Session::close_data_files_and_morph_locks(const TableIdentifier &identifier)
 
1225
void Session::close_data_files_and_morph_locks(const identifier::Table &identifier)
1226
1226
{
1227
1227
  safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle()); /* Adjust locks at the end of ALTER TABLEL */
1228
1228
 
1461
1461
*/
1462
1462
 
1463
1463
 
1464
 
Table *drop_locked_tables(Session *session, const drizzled::TableIdentifier &identifier)
 
1464
Table *drop_locked_tables(Session *session, const drizzled::identifier::Table &identifier)
1465
1465
{
1466
1466
  Table *table,*next,**prev, *found= 0;
1467
1467
  prev= &session->open_tables;
1516
1516
  other threads trying to get the lock.
1517
1517
*/
1518
1518
 
1519
 
void abort_locked_tables(Session *session, const drizzled::TableIdentifier &identifier)
 
1519
void abort_locked_tables(Session *session, const drizzled::identifier::Table &identifier)
1520
1520
{
1521
1521
  Table *table;
1522
1522
  for (table= session->open_tables; table ; table= table->getNext())
1597
1597
     * to see if it exists so that an unauthorized user cannot phish for
1598
1598
     * table/schema information via error messages
1599
1599
     */
1600
 
    TableIdentifier the_table(tables->getSchemaName(), tables->getTableName());
 
1600
    identifier::Table the_table(tables->getSchemaName(), tables->getTableName());
1601
1601
    if (not plugin::Authorization::isAuthorized(user(), the_table))
1602
1602
    {
1603
1603
      result= -1;                               // Fatal error
1799
1799
#  Table object
1800
1800
*/
1801
1801
 
1802
 
Table *Open_tables_state::open_temporary_table(const TableIdentifier &identifier,
 
1802
Table *Open_tables_state::open_temporary_table(const identifier::Table &identifier,
1803
1803
                                               bool link_in_list)
1804
1804
{
1805
1805
  assert(identifier.isTmp());
1807
1807
 
1808
1808
  table::Temporary *new_tmp_table= new table::Temporary(identifier.getType(),
1809
1809
                                                        identifier,
1810
 
                                                        const_cast<char *>(const_cast<TableIdentifier&>(identifier).getPath().c_str()),
 
1810
                                                        const_cast<char *>(const_cast<identifier::Table&>(identifier).getPath().c_str()),
1811
1811
                                                        static_cast<uint32_t>(identifier.getPath().length()));
1812
1812
  if (not new_tmp_table)
1813
1813
    return NULL;