~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Brian Aker
  • Date: 2009-06-02 08:22:40 UTC
  • mto: This revision was merged to the branch mainline in revision 1047.
  • Revision ID: brian@gaz-20090602082240-02qgwqy6qq102n4g
Remove dead code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
731
731
}
732
732
 
733
733
 
734
 
/*
735
 
  Close all tables which match specified connection string or
736
 
  if specified string is NULL, then any table with a connection string.
737
 
*/
738
 
 
739
 
bool close_cached_connection_tables(Session *session, bool if_wait_for_refresh,
740
 
                                    LEX_STRING *connection, bool have_lock)
741
 
{
742
 
  uint32_t idx;
743
 
  TableList tmp, *tables= NULL;
744
 
  bool result= false;
745
 
  assert(session);
746
 
 
747
 
  if (!have_lock)
748
 
    pthread_mutex_lock(&LOCK_open);
749
 
 
750
 
  for (idx= 0; idx < table_def_cache.records; idx++)
751
 
  {
752
 
    TableShare *share= (TableShare *) hash_element(&table_def_cache, idx);
753
 
 
754
 
    /* Ignore if table is not open or does not have a connect_string */
755
 
    if (!share->connect_string.length || !share->ref_count)
756
 
      continue;
757
 
 
758
 
    /* Compare the connection string */
759
 
    if (connection &&
760
 
        (connection->length > share->connect_string.length ||
761
 
         (connection->length < share->connect_string.length &&
762
 
          (share->connect_string.str[connection->length] != '/' &&
763
 
           share->connect_string.str[connection->length] != '\\')) ||
764
 
         strncasecmp(connection->str, share->connect_string.str,
765
 
                     connection->length)))
766
 
      continue;
767
 
 
768
 
    /* close_cached_tables() only uses these elements */
769
 
    tmp.db= share->db.str;
770
 
    tmp.table_name= share->table_name.str;
771
 
    tmp.next_local= tables;
772
 
 
773
 
    tables= (TableList *) memdup_root(session->mem_root, (char*)&tmp,
774
 
                                      sizeof(TableList));
775
 
  }
776
 
 
777
 
  if (tables)
778
 
    result= close_cached_tables(session, tables, true, false, false);
779
 
 
780
 
  if (!have_lock)
781
 
    pthread_mutex_unlock(&LOCK_open);
782
 
 
783
 
  if (if_wait_for_refresh)
784
 
  {
785
 
    pthread_mutex_lock(&session->mysys_var->mutex);
786
 
    session->mysys_var->current_mutex= 0;
787
 
    session->mysys_var->current_cond= 0;
788
 
    session->set_proc_info(0);
789
 
    pthread_mutex_unlock(&session->mysys_var->mutex);
790
 
  }
791
 
 
792
 
  return(result);
793
 
}
794
 
 
795
 
 
796
734
/**
797
735
  Auxiliary function to close all tables in the open_tables list.
798
736
 
5619
5557
 
5620
5558
 
5621
5559
/*
5622
 
  free all unused tables
5623
 
 
5624
 
  NOTE
5625
 
  This is called by 'handle_manager' when one wants to periodicly flush
5626
 
  all not used tables.
5627
 
*/
5628
 
 
5629
 
void flush_tables()
5630
 
{
5631
 
  (void) pthread_mutex_lock(&LOCK_open);
5632
 
  while (unused_tables)
5633
 
    hash_delete(&open_cache,(unsigned char*) unused_tables);
5634
 
  (void) pthread_mutex_unlock(&LOCK_open);
5635
 
}
5636
 
 
5637
 
 
5638
 
/*
5639
5560
  Mark all entries with the table as deleted to force an reopen of the table
5640
5561
 
5641
5562
  The table will be closed (not stored in cache) by the current thread when