~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/show.cc

  • Committer: Brian Aker
  • Date: 2009-06-30 00:17:07 UTC
  • mfrom: (1079.2.9 info-schema-plugin)
  • Revision ID: brian@gaz-20090630001707-33byyr838fb60u9m
MergeĀ PadraigĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
** List all table types supported
138
138
***************************************************************************/
139
139
 
140
 
class ShowPlugins : public unary_function<st_plugin_int *, bool>
141
 
{
142
 
  Session *session;
143
 
  Table *table;
144
 
public:
145
 
  ShowPlugins(Session *session_arg, Table *table_arg)
146
 
    : session(session_arg), table(table_arg) {}
147
 
 
148
 
  result_type operator() (argument_type plugin)
149
 
  {
150
 
    struct drizzled_plugin_manifest *plug= plugin_decl(plugin);
151
 
    const CHARSET_INFO * const cs= system_charset_info;
152
 
  
153
 
    table->restoreRecordAsDefault();
154
 
  
155
 
    table->field[0]->store(plugin_name(plugin)->str,
156
 
                           plugin_name(plugin)->length, cs);
157
 
  
158
 
    if (plug->version)
159
 
    {
160
 
      table->field[1]->store(plug->version, strlen(plug->version), cs);
161
 
      table->field[1]->set_notnull();
162
 
    }
163
 
    else
164
 
      table->field[1]->set_null();
165
 
  
166
 
    if (plugin->isInited)
167
 
      table->field[2]->store(STRING_WITH_LEN("ACTIVE"), cs);
168
 
    else
169
 
      table->field[2]->store(STRING_WITH_LEN("INACTIVE"), cs);
170
 
  
171
 
    if (plug->author)
172
 
    {
173
 
      table->field[3]->store(plug->author, strlen(plug->author), cs);
174
 
      table->field[3]->set_notnull();
175
 
    }
176
 
    else
177
 
      table->field[3]->set_null();
178
 
  
179
 
    if (plug->descr)
180
 
    {
181
 
      table->field[4]->store(plug->descr, strlen(plug->descr), cs);
182
 
      table->field[4]->set_notnull();
183
 
    }
184
 
    else
185
 
      table->field[4]->set_null();
186
 
  
187
 
    switch (plug->license) {
188
 
    case PLUGIN_LICENSE_GPL:
189
 
      table->field[5]->store(PLUGIN_LICENSE_GPL_STRING,
190
 
                             strlen(PLUGIN_LICENSE_GPL_STRING), cs);
191
 
      break;
192
 
    case PLUGIN_LICENSE_BSD:
193
 
      table->field[5]->store(PLUGIN_LICENSE_BSD_STRING,
194
 
                             strlen(PLUGIN_LICENSE_BSD_STRING), cs);
195
 
      break;
196
 
    case PLUGIN_LICENSE_LGPL:
197
 
      table->field[5]->store(PLUGIN_LICENSE_LGPL_STRING,
198
 
                             strlen(PLUGIN_LICENSE_LGPL_STRING), cs);
199
 
      break;
200
 
    default:
201
 
      table->field[5]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,
202
 
                             strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);
203
 
      break;
204
 
    }
205
 
    table->field[5]->set_notnull();
206
 
  
207
 
    return schema_table_store_record(session, table);
208
 
  }
209
 
};
210
 
 
211
 
 
212
 
int PluginsISMethods::fillTable(Session *session, TableList *tables, COND *)
213
 
{
214
 
  Table *table= tables->table;
215
 
 
216
 
  PluginRegistry &registry= PluginRegistry::getPluginRegistry();
217
 
  vector<st_plugin_int *> plugins= registry.get_list(true);
218
 
  vector<st_plugin_int *>::iterator iter=
219
 
    find_if(plugins.begin(), plugins.end(), ShowPlugins(session, table));
220
 
  if (iter != plugins.end())
221
 
    return 1;
222
 
  return(0);
223
 
}
224
 
 
225
 
 
226
140
/*
227
141
  find_files() - find files in a given directory.
228
142
 
1773
1687
}
1774
1688
 
1775
1689
 
1776
 
enum enum_schema_tables get_schema_table_idx(InfoSchemaTable *schema_table)
1777
 
{
1778
 
  return (enum enum_schema_tables) (schema_table - &schema_tables[0]);
1779
 
}
1780
 
 
1781
 
 
1782
1690
/*
1783
1691
  Create db names list. Information schema name always is first in list
1784
1692
 
2261
2169
  LOOKUP_FIELD_VALUES lookup_field_vals;
2262
2170
  LEX_STRING *db_name, *table_name;
2263
2171
  bool with_i_schema;
2264
 
  enum enum_schema_tables schema_table_idx;
2265
2172
  List<LEX_STRING> db_names;
2266
2173
  List_iterator_fast<LEX_STRING> it(db_names);
2267
2174
  COND *partial_cond= 0;
2279
2186
  */
2280
2187
  session->reset_n_backup_open_tables_state(&open_tables_state_backup);
2281
2188
 
2282
 
  schema_table_idx= get_schema_table_idx(schema_table);
2283
2189
  tables->table_open_method= table_open_method=
2284
2190
    get_table_open_method(tables, schema_table);
2285
2191
  /*
2366
2272
            table name or lookup value is wild string(table name list is
2367
2273
            already created by make_table_name_list() function).
2368
2274
          */
2369
 
          if (!table_open_method && schema_table_idx == SCH_TABLES &&
2370
 
              (!lookup_field_vals.table_value.length ||
 
2275
          if (! table_open_method &&
 
2276
              schema_table->getTableName().compare("TABLES") == 0 &&
 
2277
              (! lookup_field_vals.table_value.length ||
2371
2278
               lookup_field_vals.wild_table_value))
2372
2279
          {
2373
2280
            if (schema_table_store_record(session, table))
2376
2283
          }
2377
2284
 
2378
2285
          /* SHOW Table NAMES command */
2379
 
          if (schema_table_idx == SCH_TABLE_NAMES)
 
2286
          if (schema_table->getTableName().compare("TABLE_NAMES") == 0)
2380
2287
          {
2381
2288
            if (fill_schema_table_names(session, tables->table, db_name,
2382
2289
                                        table_name, with_i_schema))
3053
2960
}
3054
2961
 
3055
2962
 
3056
 
bool store_constraints(Session *session, Table *table, LEX_STRING *db_name,
3057
 
                       LEX_STRING *table_name, const char *key_name,
3058
 
                       uint32_t key_len, const char *con_type, uint32_t con_len)
3059
 
{
3060
 
  const CHARSET_INFO * const cs= system_charset_info;
3061
 
  table->restoreRecordAsDefault();
3062
 
  table->field[1]->store(db_name->str, db_name->length, cs);
3063
 
  table->field[2]->store(key_name, key_len, cs);
3064
 
  table->field[3]->store(db_name->str, db_name->length, cs);
3065
 
  table->field[4]->store(table_name->str, table_name->length, cs);
3066
 
  table->field[5]->store(con_type, con_len, cs);
3067
 
  return schema_table_store_record(session, table);
3068
 
}
3069
 
 
3070
 
 
3071
 
int TabConstraintsISMethods::processTable(Session *session, TableList *tables,
3072
 
                                         Table *table, bool res,
3073
 
                                         LEX_STRING *db_name,
3074
 
                                         LEX_STRING *table_name) const
3075
 
{
3076
 
  if (res)
3077
 
  {
3078
 
    if (session->is_error())
3079
 
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3080
 
                   session->main_da.sql_errno(), session->main_da.message());
3081
 
    session->clear_error();
3082
 
    return(0);
3083
 
  }
3084
 
  else
3085
 
  {
3086
 
    List<FOREIGN_KEY_INFO> f_key_list;
3087
 
    Table *show_table= tables->table;
3088
 
    KEY *key_info=show_table->key_info;
3089
 
    uint32_t primary_key= show_table->s->primary_key;
3090
 
    show_table->file->info(HA_STATUS_VARIABLE |
3091
 
                           HA_STATUS_NO_LOCK |
3092
 
                           HA_STATUS_TIME);
3093
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
3094
 
    {
3095
 
      if (i != primary_key && !(key_info->flags & HA_NOSAME))
3096
 
        continue;
3097
 
 
3098
 
      if (i == primary_key && is_primary_key(key_info))
3099
 
      {
3100
 
        if (store_constraints(session, table, db_name, table_name, key_info->name,
3101
 
                              strlen(key_info->name),
3102
 
                              STRING_WITH_LEN("PRIMARY KEY")))
3103
 
          return(1);
3104
 
      }
3105
 
      else if (key_info->flags & HA_NOSAME)
3106
 
      {
3107
 
        if (store_constraints(session, table, db_name, table_name, key_info->name,
3108
 
                              strlen(key_info->name),
3109
 
                              STRING_WITH_LEN("UNIQUE")))
3110
 
          return(1);
3111
 
      }
3112
 
    }
3113
 
 
3114
 
    show_table->file->get_foreign_key_list(session, &f_key_list);
3115
 
    FOREIGN_KEY_INFO *f_key_info;
3116
 
    List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
3117
 
    while ((f_key_info=it++))
3118
 
    {
3119
 
      if (store_constraints(session, table, db_name, table_name,
3120
 
                            f_key_info->forein_id->str,
3121
 
                            strlen(f_key_info->forein_id->str),
3122
 
                            "FOREIGN KEY", 11))
3123
 
        return(1);
3124
 
    }
3125
 
  }
3126
 
  return(res);
3127
 
}
3128
 
 
3129
 
 
3130
 
void store_key_column_usage(Table *table, LEX_STRING *db_name,
3131
 
                            LEX_STRING *table_name, const char *key_name,
3132
 
                            uint32_t key_len, const char *con_type, uint32_t con_len,
3133
 
                            int64_t idx)
3134
 
{
3135
 
  const CHARSET_INFO * const cs= system_charset_info;
3136
 
  table->field[1]->store(db_name->str, db_name->length, cs);
3137
 
  table->field[2]->store(key_name, key_len, cs);
3138
 
  table->field[4]->store(db_name->str, db_name->length, cs);
3139
 
  table->field[5]->store(table_name->str, table_name->length, cs);
3140
 
  table->field[6]->store(con_type, con_len, cs);
3141
 
  table->field[7]->store((int64_t) idx, true);
3142
 
}
3143
 
 
3144
 
 
3145
 
int KeyColUsageISMethods::processTable(Session *session,
3146
 
                                              TableList *tables,
3147
 
                                              Table *table, bool res,
3148
 
                                              LEX_STRING *db_name,
3149
 
                                              LEX_STRING *table_name) const
3150
 
{
3151
 
  if (res)
3152
 
  {
3153
 
    if (session->is_error())
3154
 
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3155
 
                   session->main_da.sql_errno(), session->main_da.message());
3156
 
    session->clear_error();
3157
 
    return(0);
3158
 
  }
3159
 
  else
3160
 
  {
3161
 
    List<FOREIGN_KEY_INFO> f_key_list;
3162
 
    Table *show_table= tables->table;
3163
 
    KEY *key_info=show_table->key_info;
3164
 
    uint32_t primary_key= show_table->s->primary_key;
3165
 
    show_table->file->info(HA_STATUS_VARIABLE |
3166
 
                           HA_STATUS_NO_LOCK |
3167
 
                           HA_STATUS_TIME);
3168
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
3169
 
    {
3170
 
      if (i != primary_key && !(key_info->flags & HA_NOSAME))
3171
 
        continue;
3172
 
      uint32_t f_idx= 0;
3173
 
      KEY_PART_INFO *key_part= key_info->key_part;
3174
 
      for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
3175
 
      {
3176
 
        if (key_part->field)
3177
 
        {
3178
 
          f_idx++;
3179
 
          table->restoreRecordAsDefault();
3180
 
          store_key_column_usage(table, db_name, table_name,
3181
 
                                 key_info->name,
3182
 
                                 strlen(key_info->name),
3183
 
                                 key_part->field->field_name,
3184
 
                                 strlen(key_part->field->field_name),
3185
 
                                 (int64_t) f_idx);
3186
 
          if (schema_table_store_record(session, table))
3187
 
            return(1);
3188
 
        }
3189
 
      }
3190
 
    }
3191
 
 
3192
 
    show_table->file->get_foreign_key_list(session, &f_key_list);
3193
 
    FOREIGN_KEY_INFO *f_key_info;
3194
 
    List_iterator_fast<FOREIGN_KEY_INFO> fkey_it(f_key_list);
3195
 
    while ((f_key_info= fkey_it++))
3196
 
    {
3197
 
      LEX_STRING *f_info;
3198
 
      LEX_STRING *r_info;
3199
 
      List_iterator_fast<LEX_STRING> it(f_key_info->foreign_fields),
3200
 
        it1(f_key_info->referenced_fields);
3201
 
      uint32_t f_idx= 0;
3202
 
      while ((f_info= it++))
3203
 
      {
3204
 
        r_info= it1++;
3205
 
        f_idx++;
3206
 
        table->restoreRecordAsDefault();
3207
 
        store_key_column_usage(table, db_name, table_name,
3208
 
                               f_key_info->forein_id->str,
3209
 
                               f_key_info->forein_id->length,
3210
 
                               f_info->str, f_info->length,
3211
 
                               (int64_t) f_idx);
3212
 
        table->field[8]->store((int64_t) f_idx, true);
3213
 
        table->field[8]->set_notnull();
3214
 
        table->field[9]->store(f_key_info->referenced_db->str,
3215
 
                               f_key_info->referenced_db->length,
3216
 
                               system_charset_info);
3217
 
        table->field[9]->set_notnull();
3218
 
        table->field[10]->store(f_key_info->referenced_table->str,
3219
 
                                f_key_info->referenced_table->length,
3220
 
                                system_charset_info);
3221
 
        table->field[10]->set_notnull();
3222
 
        table->field[11]->store(r_info->str, r_info->length,
3223
 
                                system_charset_info);
3224
 
        table->field[11]->set_notnull();
3225
 
        if (schema_table_store_record(session, table))
3226
 
          return(1);
3227
 
      }
3228
 
    }
3229
 
  }
3230
 
  return(res);
3231
 
}
3232
 
 
3233
 
 
3234
2963
int OpenTablesISMethods::fillTable(Session *session, TableList *tables, COND *)
3235
2964
{
3236
2965
  const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
3260
2989
  int res= 0;
3261
2990
  LEX *lex= session->lex;
3262
2991
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
3263
 
  enum enum_schema_tables schema_table_idx=
3264
 
    get_schema_table_idx(tables->schema_table);
 
2992
  const string schema_table_name= tables->schema_table->getTableName();
3265
2993
  enum enum_var_type option_type= OPT_SESSION;
3266
 
  bool upper_case_names= (schema_table_idx != SCH_VARIABLES);
3267
 
  bool sorted_vars= (schema_table_idx == SCH_VARIABLES);
 
2994
  bool upper_case_names= (schema_table_name.compare("VARIABLES") != 0);
 
2995
  bool sorted_vars= (schema_table_name.compare("VARIABLES") == 0);
3268
2996
 
3269
2997
  if (lex->option_type == OPT_GLOBAL ||
3270
 
      schema_table_idx == SCH_GLOBAL_VARIABLES)
 
2998
      schema_table_name.compare("GLOBAL_VARIABLES") == 0)
 
2999
  {
3271
3000
    option_type= OPT_GLOBAL;
 
3001
  }
3272
3002
 
3273
3003
  pthread_rwlock_rdlock(&LOCK_system_variables_hash);
3274
3004
  res= show_status_array(session, wild, enumerate_sys_vars(session, sorted_vars),
3284
3014
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
3285
3015
  int res= 0;
3286
3016
  STATUS_VAR *tmp1, tmp;
3287
 
  enum enum_schema_tables schema_table_idx=
3288
 
    get_schema_table_idx(tables->schema_table);
 
3017
  const string schema_table_name= tables->schema_table->getTableName();
3289
3018
  enum enum_var_type option_type;
3290
 
  bool upper_case_names= (schema_table_idx != SCH_STATUS);
 
3019
  bool upper_case_names= (schema_table_name.compare("STATUS") != 0);
3291
3020
 
3292
 
  if (schema_table_idx == SCH_STATUS)
 
3021
  if (schema_table_name.compare("STATUS") == 0)
3293
3022
  {
3294
3023
    option_type= lex->option_type;
3295
3024
    if (option_type == OPT_GLOBAL)
3297
3026
    else
3298
3027
      tmp1= session->initial_status_var;
3299
3028
  }
3300
 
  else if (schema_table_idx == SCH_GLOBAL_STATUS)
 
3029
  else if (schema_table_name.compare("GLOBAL_STATUS") == 0)
3301
3030
  {
3302
3031
    option_type= OPT_GLOBAL;
3303
3032
    tmp1= &tmp;
3320
3049
}
3321
3050
 
3322
3051
 
3323
 
/*
3324
 
  Fill and store records into I_S.referential_constraints table
3325
 
 
3326
 
  SYNOPSIS
3327
 
    RefConstraintsISMethods::processTable()
3328
 
    session                 thread handle
3329
 
    tables              table list struct(processed table)
3330
 
    table               I_S table
3331
 
    res                 1 means the error during opening of the processed table
3332
 
                        0 means processed table is opened without error
3333
 
    base_name           db name
3334
 
    file_name           table name
3335
 
 
3336
 
  RETURN
3337
 
    0   ok
3338
 
    #   error
3339
 
*/
3340
 
 
3341
 
int
3342
 
RefConstraintsISMethods::processTable(Session *session, TableList *tables,
3343
 
                                      Table *table, bool res,
3344
 
                                      LEX_STRING *db_name, LEX_STRING *table_name)
3345
 
  const
3346
 
{
3347
 
  const CHARSET_INFO * const cs= system_charset_info;
3348
 
 
3349
 
  if (res)
3350
 
  {
3351
 
    if (session->is_error())
3352
 
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3353
 
                   session->main_da.sql_errno(), session->main_da.message());
3354
 
    session->clear_error();
3355
 
    return(0);
3356
 
  }
3357
 
 
3358
 
  {
3359
 
    List<FOREIGN_KEY_INFO> f_key_list;
3360
 
    Table *show_table= tables->table;
3361
 
    show_table->file->info(HA_STATUS_VARIABLE |
3362
 
                           HA_STATUS_NO_LOCK |
3363
 
                           HA_STATUS_TIME);
3364
 
 
3365
 
    show_table->file->get_foreign_key_list(session, &f_key_list);
3366
 
    FOREIGN_KEY_INFO *f_key_info;
3367
 
    List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
3368
 
    while ((f_key_info= it++))
3369
 
    {
3370
 
      table->restoreRecordAsDefault();
3371
 
      table->field[1]->store(db_name->str, db_name->length, cs);
3372
 
      table->field[9]->store(table_name->str, table_name->length, cs);
3373
 
      table->field[2]->store(f_key_info->forein_id->str,
3374
 
                             f_key_info->forein_id->length, cs);
3375
 
      table->field[4]->store(f_key_info->referenced_db->str,
3376
 
                             f_key_info->referenced_db->length, cs);
3377
 
      table->field[10]->store(f_key_info->referenced_table->str,
3378
 
                             f_key_info->referenced_table->length, cs);
3379
 
      if (f_key_info->referenced_key_name)
3380
 
      {
3381
 
        table->field[5]->store(f_key_info->referenced_key_name->str,
3382
 
                               f_key_info->referenced_key_name->length, cs);
3383
 
        table->field[5]->set_notnull();
3384
 
      }
3385
 
      else
3386
 
        table->field[5]->set_null();
3387
 
      table->field[6]->store(STRING_WITH_LEN("NONE"), cs);
3388
 
      table->field[7]->store(f_key_info->update_method->str,
3389
 
                             f_key_info->update_method->length, cs);
3390
 
      table->field[8]->store(f_key_info->delete_method->str,
3391
 
                             f_key_info->delete_method->length, cs);
3392
 
      if (schema_table_store_record(session, table))
3393
 
        return(1);
3394
 
    }
3395
 
  }
3396
 
  return(0);
3397
 
}
3398
 
 
3399
 
 
3400
3052
class FindSchemaTableByName : public unary_function<InfoSchemaTable *, bool>
3401
3053
{
3402
3054
  const char *table_name;
3445
3097
}
3446
3098
 
3447
3099
 
3448
 
InfoSchemaTable *get_schema_table(enum enum_schema_tables schema_table_idx)
3449
 
{
3450
 
  return &schema_tables[schema_table_idx];
3451
 
}
3452
 
 
3453
 
 
3454
3100
Table *InfoSchemaMethods::createSchemaTable(Session *session, TableList *table_list)
3455
3101
  const
3456
3102
{
3744
3390
    make_schema_select()
3745
3391
    session                  thread handler
3746
3392
    sel                  pointer to Select_Lex
3747
 
    schema_table_idx     index of 'schema_tables' element
 
3393
    schema_table_name    name of 'schema_tables' element
3748
3394
 
3749
3395
  RETURN
3750
3396
    true on error
3751
3397
*/
3752
3398
 
3753
3399
bool make_schema_select(Session *session, Select_Lex *sel,
3754
 
                        enum enum_schema_tables schema_table_idx)
 
3400
                        const string& schema_table_name)
3755
3401
{
3756
 
  InfoSchemaTable *schema_table= get_schema_table(schema_table_idx);
 
3402
  InfoSchemaTable *schema_table= find_schema_table(schema_table_name.c_str());
3757
3403
  LEX_STRING db, table;
3758
3404
  /*
3759
3405
     We have to make non const db_name & table_name
4010
3656
};
4011
3657
 
4012
3658
 
4013
 
ColumnInfo table_constraints_fields_info[]=
4014
 
{
4015
 
  ColumnInfo("CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FULL_TABLE),
4016
 
  ColumnInfo("CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4017
 
   "", OPEN_FULL_TABLE),
4018
 
  ColumnInfo("CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4019
 
   "", OPEN_FULL_TABLE),
4020
 
  ColumnInfo("TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4021
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4022
 
  ColumnInfo("CONSTRAINT_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 
4023
 
   "", OPEN_FULL_TABLE),
4024
 
  ColumnInfo()
4025
 
};
4026
 
 
4027
 
 
4028
 
ColumnInfo key_column_usage_fields_info[]=
4029
 
{
4030
 
  ColumnInfo("CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FULL_TABLE),
4031
 
  ColumnInfo("CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4032
 
   "", OPEN_FULL_TABLE),
4033
 
  ColumnInfo("CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4034
 
   "", OPEN_FULL_TABLE),
4035
 
  ColumnInfo("TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FULL_TABLE),
4036
 
  ColumnInfo("TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4037
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4038
 
  "", OPEN_FULL_TABLE),
4039
 
  ColumnInfo("COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4040
 
  ColumnInfo("ORDINAL_POSITION", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 0, "", OPEN_FULL_TABLE),
4041
 
  ColumnInfo("POSITION_IN_UNIQUE_CONSTRAINT", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 1,
4042
 
   "", OPEN_FULL_TABLE),
4043
 
  ColumnInfo("REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1,
4044
 
   "", OPEN_FULL_TABLE),
4045
 
  ColumnInfo("REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1,
4046
 
   "", OPEN_FULL_TABLE),
4047
 
  ColumnInfo("REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1,
4048
 
   "", OPEN_FULL_TABLE),
4049
 
  ColumnInfo()
4050
 
};
4051
 
 
4052
 
 
4053
3659
ColumnInfo table_names_fields_info[]=
4054
3660
{
4055
3661
  ColumnInfo("TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", SKIP_OPEN_TABLE),
4082
3688
};
4083
3689
 
4084
3690
 
4085
 
ColumnInfo plugin_fields_info[]=
4086
 
{
4087
 
  ColumnInfo("PLUGIN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name",
4088
 
   SKIP_OPEN_TABLE),
4089
 
  ColumnInfo("PLUGIN_VERSION", 20, DRIZZLE_TYPE_VARCHAR, 0, 0, "", SKIP_OPEN_TABLE),
4090
 
  ColumnInfo("PLUGIN_STATUS", 10, DRIZZLE_TYPE_VARCHAR, 0, 0, "Status", SKIP_OPEN_TABLE),
4091
 
  ColumnInfo("PLUGIN_AUTHOR", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", SKIP_OPEN_TABLE),
4092
 
  ColumnInfo("PLUGIN_DESCRIPTION", 65535, DRIZZLE_TYPE_VARCHAR, 0, 1, "", SKIP_OPEN_TABLE),
4093
 
  ColumnInfo("PLUGIN_LICENSE", 80, DRIZZLE_TYPE_VARCHAR, 0, 1, "License", SKIP_OPEN_TABLE),
4094
 
  ColumnInfo()
4095
 
};
4096
 
 
4097
 
ColumnInfo referential_constraints_fields_info[]=
4098
 
{
4099
 
  ColumnInfo("CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FULL_TABLE),
4100
 
  ColumnInfo("CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4101
 
   "", OPEN_FULL_TABLE),
4102
 
  ColumnInfo("CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4103
 
   "", OPEN_FULL_TABLE),
4104
 
  ColumnInfo("UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1,
4105
 
   "", OPEN_FULL_TABLE),
4106
 
  ColumnInfo("UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4107
 
   "", OPEN_FULL_TABLE),
4108
 
  ColumnInfo("UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0,
4109
 
   MY_I_S_MAYBE_NULL, "", OPEN_FULL_TABLE),
4110
 
  ColumnInfo("MATCH_OPTION", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4111
 
  ColumnInfo("UPDATE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4112
 
  ColumnInfo("DELETE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4113
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4114
 
  ColumnInfo("REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4115
 
   "", OPEN_FULL_TABLE),
4116
 
  ColumnInfo()
4117
 
};
4118
 
 
4119
3691
static ColumnsISMethods columns_methods;
4120
3692
static StatusISMethods status_methods;
4121
3693
static VariablesISMethods variables_methods;
4122
 
static KeyColUsageISMethods key_col_usage_methods;
4123
3694
static OpenTablesISMethods open_tables_methods;
4124
 
static PluginsISMethods plugins_methods;
4125
 
static RefConstraintsISMethods ref_constraints_methods;
4126
3695
static SchemataISMethods schemata_methods;
4127
3696
static StatsISMethods stats_methods;
4128
3697
static TablesISMethods tables_methods;
4129
 
static TabConstraintsISMethods tab_constraints_methods;
4130
3698
static TabNamesISMethods tab_names_methods;
4131
3699
 
4132
3700
static InfoSchemaTable columns_table("COLUMNS",
4141
3709
                                        variables_fields_info,
4142
3710
                                        -1, -1, false, false, 0,
4143
3711
                                        &variables_methods);
4144
 
static InfoSchemaTable key_col_usage_table("KEY_COLUMN_USAGE",
4145
 
                                           key_column_usage_fields_info,
4146
 
                                           4, 5, false, true, OPEN_TABLE_ONLY,
4147
 
                                           &key_col_usage_methods);
4148
3712
static InfoSchemaTable open_tab_table("OPEN_TABLES",
4149
3713
                                      open_tables_fields_info,
4150
3714
                                      -1, -1, true, false, 0,
4151
3715
                                      &open_tables_methods);
4152
 
static InfoSchemaTable plugins_table("PLUGINS",
4153
 
                                     plugin_fields_info,
4154
 
                                     -1, -1, false, false, 0,
4155
 
                                     &plugins_methods);
4156
 
static InfoSchemaTable ref_constrain_table("REFERENTIAL_CONSTRAINTS",
4157
 
                                           referential_constraints_fields_info,
4158
 
                                           1, 9, false, true, OPEN_TABLE_ONLY,
4159
 
                                           &ref_constraints_methods);
4160
3716
static InfoSchemaTable schemata_table("SCHEMATA",
4161
3717
                                      schema_fields_info,
4162
3718
                                      1, -1, false, false, 0,
4182
3738
                                    tables_fields_info,
4183
3739
                                    1, 2, false, true, OPTIMIZE_I_S_TABLE,
4184
3740
                                    &tables_methods);
4185
 
static InfoSchemaTable tab_constrain_table("TABLE_CONSTRAINTS",
4186
 
                                           table_constraints_fields_info,
4187
 
                                           3, 4, false, true, OPEN_TABLE_ONLY,
4188
 
                                           &tab_constraints_methods);
4189
3741
static InfoSchemaTable tab_names_table("TABLE_NAMES",
4190
3742
                                       table_names_fields_info,
4191
3743
                                       1, 2, true, true, 0,
4195
3747
                                 -1, -1, true, false, 0,
4196
3748
                                 &variables_methods);
4197
3749
 
4198
 
/**
4199
 
 * @note
4200
 
 *   Make sure that the order of schema_tables and enum_schema_tables are the same.
4201
 
 */
4202
 
 
4203
3750
InfoSchemaTable schema_tables[]=
4204
3751
{
4205
3752
  columns_table,
4206
3753
  global_stat_table,
4207
3754
  global_var_table,
4208
 
  key_col_usage_table,
4209
3755
  open_tab_table,
4210
 
  plugins_table,
4211
 
  ref_constrain_table,
4212
3756
  schemata_table,
4213
3757
  sess_stat_table,
4214
3758
  sess_var_table,
4215
3759
  stats_table,
4216
3760
  status_table,
4217
3761
  tables_table,
4218
 
  tab_constrain_table,
4219
3762
  tab_names_table,
4220
3763
  var_table,
4221
3764
  InfoSchemaTable()