~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Stewart Smith
  • Date: 2010-03-23 05:34:52 UTC
  • mfrom: (1283.13.15)
  • mto: (1283.11.20)
  • mto: This revision was merged to the branch mainline in revision 1449.
  • Revision ID: stewart@flamingspork.com-20100323053452-p0w9rnmin9c9j2vr
Merged embedded-innodb-settings into embedded-innodb-dump-datadict-func.

Show diffs side-by-side

added added

removed removed

Lines of Context:
416
416
      Open placeholders have Table::db_stat set to 0, so they should be
417
417
      handled by the first alternative.
418
418
    */
419
 
    assert(!table->open_placeholder);
 
419
    assert(not table->open_placeholder);
420
420
 
421
421
    /* Free memory and reset for next loop */
422
422
    table->cursor->ha_reset();
605
605
  {
606
606
    if (table->s->tmp_table == TEMP_TABLE)
607
607
    {
608
 
      if (not strcmp(identifier.getSchemaName().c_str(), table->s->getSchemaName()))
 
608
      if (not identifier.getSchemaName().compare(table->s->getSchemaName()))
609
609
      {
610
 
        if (not strcmp(identifier.getTableName().c_str(), table->s->table_name.str))
 
610
        if (not identifier.getTableName().compare(table->s->table_name.str))
611
611
        {
612
612
          return true;
613
613
        }
625
625
  {
626
626
    if (table->s->tmp_table == TEMP_TABLE)
627
627
    {
628
 
      if (not strcmp(identifier.getSchemaName().c_str(), table->s->getSchemaName()))
 
628
      if (not identifier.getSchemaName().compare(table->s->getSchemaName()))
629
629
      {
630
 
        if (not strcmp(identifier.getTableName().c_str(), table->s->table_name.str))
 
630
        if (not identifier.getTableName().compare(table->s->table_name.str))
631
631
        {
632
632
          table_proto.CopyFrom(*(table->s->getTableProto()));
633
633
 
644
644
{
645
645
  char  key[MAX_DBKEY_LENGTH];
646
646
  uint  key_length;
647
 
  Table *table;
648
647
 
649
648
  key_length= TableShare::createKey(key, new_db, table_name);
650
649
 
651
 
  for (table= temporary_tables ; table ; table= table->next)
 
650
  for (Table *table= temporary_tables ; table ; table= table->next)
652
651
  {
653
652
    if (table->s->table_cache_key.length == key_length &&
654
 
        !memcmp(table->s->table_cache_key.str, key, key_length))
 
653
        not memcmp(table->s->table_cache_key.str, key, key_length))
 
654
    {
655
655
      return table;
 
656
    }
656
657
  }
657
658
  return NULL;                               // Not a temporary table
658
659
}
662
663
  return find_temporary_table(table_list->db, table_list->table_name);
663
664
}
664
665
 
 
666
Table *Session::find_temporary_table(TableIdentifier &identifier)
 
667
{
 
668
  char  key[MAX_DBKEY_LENGTH];
 
669
  uint  key_length;
 
670
 
 
671
  key_length= TableShare::createKey(key, identifier);
 
672
 
 
673
  for (Table *table= temporary_tables ; table ; table= table->next)
 
674
  {
 
675
    if (table->s->table_cache_key.length == key_length &&
 
676
        not memcmp(table->s->table_cache_key.str, key, key_length))
 
677
 
 
678
      return table;
 
679
  }
 
680
 
 
681
  return NULL;                               // Not a temporary table
 
682
}
 
683
 
665
684
 
666
685
/**
667
686
  Drop a temporary table.
693
712
{
694
713
  Table *table;
695
714
 
696
 
  if (!(table= find_temporary_table(table_list)))
 
715
  if (not (table= find_temporary_table(table_list)))
697
716
    return 1;
698
717
 
699
718
  /* Table might be in use by some outer statement. */
755
774
    list= *prev;
756
775
 
757
776
    if (list->s->table_cache_key.length == key_length &&
758
 
        !memcmp(list->s->table_cache_key.str, key, key_length))
 
777
        not memcmp(list->s->table_cache_key.str, key, key_length))
759
778
    {
760
779
      /* Remove table from open_tables list. */
761
780
      *prev= list->next;
793
812
  table that was locked with LOCK TABLES.
794
813
*/
795
814
 
796
 
void Session::drop_open_table(Table *table, const char *db_name,
797
 
                              const char *table_name)
 
815
void Session::drop_open_table(Table *table, TableIdentifier &identifier)
798
816
{
799
817
  if (table->s->tmp_table)
800
818
  {
808
826
      that something has happened.
809
827
    */
810
828
    unlink_open_table(table);
811
 
    TableIdentifier identifier(db_name, table_name, STANDARD_TABLE);
812
829
    quick_rm_table(*this, identifier);
813
830
    pthread_mutex_unlock(&LOCK_open);
814
831
  }
1041
1058
    *table= 0;
1042
1059
    return false;
1043
1060
  }
1044
 
  if (!(*table= table_cache_insert_placeholder(key, key_length)))
 
1061
  if (not (*table= table_cache_insert_placeholder(key, key_length)))
1045
1062
  {
1046
1063
    pthread_mutex_unlock(&LOCK_open);
1047
1064
    return true;
1929
1946
 
1930
1947
  safe_mutex_assert_owner(&LOCK_open);
1931
1948
retry:
1932
 
  if (!(share= TableShare::getShare(session, table_list, cache_key,
1933
 
                                    cache_key_length,
1934
 
                                    table_list->i_s_requested_object,
1935
 
                                    &error)))
 
1949
  if (not (share= TableShare::getShare(session, table_list, cache_key,
 
1950
                                       cache_key_length,
 
1951
                                       table_list->i_s_requested_object,
 
1952
                                       &error)))
1936
1953
    return 1;
1937
1954
 
1938
1955
  while ((error= open_table_from_share(session, share, alias,
2291
2308
  /*
2292
2309
    First open the share, and then open the table from the share we just opened.
2293
2310
  */
2294
 
  if (open_table_def(*this, share) ||
 
2311
  if (open_table_def(*this, identifier, share) ||
2295
2312
      open_table_from_share(this, share, identifier.getTableName().c_str(),
2296
2313
                            (uint32_t) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
2297
2314
                                        HA_GET_INDEX),
4422
4439
  for (uint32_t idx=0 ; idx < open_cache.records ; idx++)
4423
4440
  {
4424
4441
    Table *table=(Table*) hash_element(&open_cache,idx);
4425
 
    if (not strcmp(table->s->getSchemaName(), schema_name.c_str()))
 
4442
    if (not schema_name.compare(table->s->getSchemaName()))
4426
4443
    {
4427
4444
      table->s->version= 0L;                    /* Free when thread is ready */
4428
4445
      if (not table->in_use)