~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/show.cc

  • Committer: Brian Aker
  • Date: 2009-04-09 15:03:26 UTC
  • mfrom: (971.1.44 mordred)
  • Revision ID: brian@gaz-20090409150326-cu50yn12esijpy1c
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
static void store_key_options(Session *session, String *packet, Table *table,
66
66
                              KEY *key_info);
67
67
 
 
68
static vector<ST_SCHEMA_TABLE *> all_schema_tables;
 
69
 
 
70
static void add_infoschema_table(ST_SCHEMA_TABLE *table)
 
71
{
 
72
  all_schema_tables.push_back(table);
 
73
}
 
74
 
 
75
static void remove_infoschema_table(ST_SCHEMA_TABLE *table)
 
76
{
 
77
  all_schema_tables.erase(remove_if(all_schema_tables.begin(),
 
78
                                    all_schema_tables.end(),
 
79
                                    bind2nd(equal_to<ST_SCHEMA_TABLE *>(),
 
80
                                            table)),
 
81
                          all_schema_tables.end());
 
82
}
68
83
 
69
84
 
70
85
int wild_case_compare(const CHARSET_INFO * const cs, const char *str,const char *wildstr)
1997
2012
};
1998
2013
 
1999
2014
 
2000
 
static bool add_schema_table(Session *session, st_plugin_int *plugin,
2001
 
                                void* p_data)
 
2015
class AddSchemaTable : public unary_function<ST_SCHEMA_TABLE *, bool>
2002
2016
{
2003
 
  LEX_STRING *file_name= 0;
2004
 
  st_add_schema_table *data= (st_add_schema_table *)p_data;
2005
 
  List<LEX_STRING> *file_list= data->files;
2006
 
  const char *wild= data->wild;
2007
 
  ST_SCHEMA_TABLE *schema_table= plugin_data(plugin, ST_SCHEMA_TABLE *);
2008
 
 
2009
 
  if (schema_table->hidden)
2010
 
      return(0);
2011
 
  if (wild)
 
2017
  Session *session;
 
2018
  st_add_schema_table *data;
 
2019
public:
 
2020
  AddSchemaTable(Session *session_arg, st_add_schema_table *data_arg)
 
2021
    : session(session_arg), data(data_arg) {}
 
2022
  result_type operator() (argument_type schema_table)
2012
2023
  {
2013
 
    if (lower_case_table_names)
 
2024
    LEX_STRING *file_name= 0;
 
2025
    List<LEX_STRING> *file_list= data->files;
 
2026
    const char *wild= data->wild;
 
2027
  
 
2028
    if (schema_table->hidden)
 
2029
        return(0);
 
2030
    if (wild)
2014
2031
    {
2015
 
      if (wild_case_compare(files_charset_info,
2016
 
                            schema_table->table_name,
2017
 
                            wild))
 
2032
      if (lower_case_table_names)
 
2033
      {
 
2034
        if (wild_case_compare(files_charset_info,
 
2035
                              schema_table->table_name,
 
2036
                              wild))
 
2037
          return(0);
 
2038
      }
 
2039
      else if (wild_compare(schema_table->table_name, wild, 0))
2018
2040
        return(0);
2019
2041
    }
2020
 
    else if (wild_compare(schema_table->table_name, wild, 0))
 
2042
  
 
2043
    if ((file_name= session->make_lex_string(file_name, schema_table->table_name,
 
2044
                                         strlen(schema_table->table_name),
 
2045
                                         true)) &&
 
2046
        !file_list->push_back(file_name))
2021
2047
      return(0);
 
2048
    return(1);
2022
2049
  }
2023
 
 
2024
 
  if ((file_name= session->make_lex_string(file_name, schema_table->table_name,
2025
 
                                       strlen(schema_table->table_name),
2026
 
                                       true)) &&
2027
 
      !file_list->push_back(file_name))
2028
 
    return(0);
2029
 
  return(1);
2030
 
}
 
2050
};
2031
2051
 
2032
2052
 
2033
2053
int schema_tables_add(Session *session, List<LEX_STRING> *files, const char *wild)
2062
2082
 
2063
2083
  add_data.files= files;
2064
2084
  add_data.wild= wild;
2065
 
  if (plugin_foreach(session, add_schema_table,
2066
 
                     DRIZZLE_INFORMATION_SCHEMA_PLUGIN, &add_data))
2067
 
    return(1);
2068
 
 
2069
 
  return(0);
 
2085
  vector<ST_SCHEMA_TABLE *>::iterator iter=
 
2086
    find_if(all_schema_tables.begin(), all_schema_tables.end(),
 
2087
           AddSchemaTable(session, &add_data));
 
2088
  if (iter != all_schema_tables.end())
 
2089
    return 1;
 
2090
  return 0 ;
2070
2091
}
2071
2092
 
2072
2093
 
3641
3662
}
3642
3663
 
3643
3664
 
3644
 
struct schema_table_ref
 
3665
class FindSchemaTableByName : public unary_function<ST_SCHEMA_TABLE *, bool>
3645
3666
{
3646
3667
  const char *table_name;
3647
 
  ST_SCHEMA_TABLE *schema_table;
 
3668
public:
 
3669
  FindSchemaTableByName(const char *table_name_arg)
 
3670
    : table_name(table_name_arg) {}
 
3671
  result_type operator() (argument_type schema_table)
 
3672
  {
 
3673
    return !my_strcasecmp(system_charset_info,
 
3674
                          schema_table->table_name,
 
3675
                          table_name);
 
3676
  }
3648
3677
};
3649
3678
 
3650
3679
 
3652
3681
  Find schema_tables elment by name
3653
3682
 
3654
3683
  SYNOPSIS
3655
 
    find_schema_table_in_plugin()
3656
 
    session                 thread handler
3657
 
    plugin              plugin
3658
 
    table_name          table name
3659
 
 
3660
 
  RETURN
3661
 
    0   table not found
3662
 
    1   found the schema table
3663
 
*/
3664
 
static bool find_schema_table_in_plugin(Session *, st_plugin_int *plugin,
3665
 
                                        void* p_table)
3666
 
{
3667
 
  schema_table_ref *p_schema_table= (schema_table_ref *)p_table;
3668
 
  const char* table_name= p_schema_table->table_name;
3669
 
  ST_SCHEMA_TABLE *schema_table= plugin_data(plugin, ST_SCHEMA_TABLE *);
3670
 
 
3671
 
  if (!my_strcasecmp(system_charset_info,
3672
 
                     schema_table->table_name,
3673
 
                     table_name)) {
3674
 
    p_schema_table->schema_table= schema_table;
3675
 
    return(1);
3676
 
  }
3677
 
 
3678
 
  return(0);
3679
 
}
3680
 
 
3681
 
 
3682
 
/*
3683
 
  Find schema_tables elment by name
3684
 
 
3685
 
  SYNOPSIS
3686
3684
    find_schema_table()
3687
3685
    session                 thread handler
3688
3686
    table_name          table name
3692
3690
    #   pointer to 'schema_tables' element
3693
3691
*/
3694
3692
 
3695
 
ST_SCHEMA_TABLE *find_schema_table(Session *session, const char* table_name)
 
3693
ST_SCHEMA_TABLE *find_schema_table(Session *, const char* table_name)
3696
3694
{
3697
 
  schema_table_ref schema_table_a;
3698
3695
  ST_SCHEMA_TABLE *schema_table= schema_tables;
3699
3696
 
3700
3697
  for (; schema_table->table_name; schema_table++)
3705
3702
      return(schema_table);
3706
3703
  }
3707
3704
 
3708
 
  schema_table_a.table_name= table_name;
3709
 
  if (plugin_foreach(session, find_schema_table_in_plugin,
3710
 
                     DRIZZLE_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
3711
 
    return(schema_table_a.schema_table);
3712
 
 
 
3705
  vector<ST_SCHEMA_TABLE *>::iterator iter= 
 
3706
    find_if(all_schema_tables.begin(), all_schema_tables.end(),
 
3707
            FindSchemaTableByName(table_name));
 
3708
  if (iter != all_schema_tables.end())
 
3709
    return *iter;
3713
3710
  return(NULL);
3714
3711
}
3715
3712
 
4516
4513
    schema_table->table_name= plugin->name.str;
4517
4514
  }
4518
4515
 
 
4516
  add_infoschema_table(schema_table);
4519
4517
  plugin->data= schema_table;
4520
4518
 
4521
4519
  return 0;
4525
4523
{
4526
4524
  ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE *)plugin->data;
4527
4525
 
 
4526
  remove_infoschema_table(schema_table);
4528
4527
  if (schema_table && plugin->plugin->deinit)
4529
4528
    plugin->plugin->deinit(schema_table);
4530
4529