~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/info_schema/info_schema.cc

Merge for Padraig 

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "info_schema_methods.h"
31
31
#include "info_schema_columns.h"
32
32
 
 
33
#include <vector>
 
34
 
33
35
using namespace std;
34
36
 
35
37
/*
38
40
static vector<const ColumnInfo *> char_set_columns;
39
41
static vector<const ColumnInfo *> collation_columns;
40
42
static vector<const ColumnInfo *> coll_char_columns;
 
43
static vector<const ColumnInfo *> col_columns;
41
44
static vector<const ColumnInfo *> key_col_usage_columns;
 
45
static vector<const ColumnInfo *> open_tab_columns;
42
46
static vector<const ColumnInfo *> plugin_columns;
43
47
static vector<const ColumnInfo *> processlist_columns;
44
48
static vector<const ColumnInfo *> ref_constraint_columns;
 
49
static vector<const ColumnInfo *> schemata_columns;
 
50
static vector<const ColumnInfo *> stats_columns;
45
51
static vector<const ColumnInfo *> tab_constraints_columns;
 
52
static vector<const ColumnInfo *> tables_columns;
 
53
static vector<const ColumnInfo *> tab_names_columns;
46
54
 
47
55
/*
48
56
 * Methods for various I_S tables.
50
58
static InfoSchemaMethods *char_set_methods= NULL;
51
59
static InfoSchemaMethods *collation_methods= NULL;
52
60
static InfoSchemaMethods *coll_char_methods= NULL;
 
61
static InfoSchemaMethods *columns_methods= NULL;
53
62
static InfoSchemaMethods *key_col_usage_methods= NULL;
 
63
static InfoSchemaMethods *open_tab_methods= NULL;
54
64
static InfoSchemaMethods *plugins_methods= NULL;
55
65
static InfoSchemaMethods *processlist_methods= NULL;
56
66
static InfoSchemaMethods *ref_constraint_methods= NULL;
 
67
static InfoSchemaMethods *schemata_methods= NULL;
 
68
static InfoSchemaMethods *stats_methods= NULL;
57
69
static InfoSchemaMethods *tab_constraints_methods= NULL;
 
70
static InfoSchemaMethods *tables_methods= NULL;
 
71
static InfoSchemaMethods *tab_names_methods= NULL;
58
72
 
59
73
/*
60
74
 * I_S tables.
62
76
static InfoSchemaTable *char_set_table= NULL;
63
77
static InfoSchemaTable *collation_table= NULL;
64
78
static InfoSchemaTable *coll_char_set_table= NULL;
 
79
static InfoSchemaTable *columns_table= NULL;
65
80
static InfoSchemaTable *key_col_usage_table= NULL;
 
81
static InfoSchemaTable *open_tab_table= NULL;
66
82
static InfoSchemaTable *plugins_table= NULL;
67
83
static InfoSchemaTable *processlist_table= NULL;
68
84
static InfoSchemaTable *ref_constraint_table= NULL;
 
85
static InfoSchemaTable *schemata_table= NULL;
 
86
static InfoSchemaTable *stats_table= NULL;
69
87
static InfoSchemaTable *tab_constraints_table= NULL;
 
88
static InfoSchemaTable *tables_table= NULL;
 
89
static InfoSchemaTable *tab_names_table= NULL;
70
90
 
71
91
/**
72
92
 * Populate the vectors of columns for each I_S table.
92
112
    return true;
93
113
  }
94
114
 
 
115
  if ((retval= createColColumns(col_columns)) == true)
 
116
  {
 
117
    return true;
 
118
  }
 
119
 
95
120
  if ((retval= createKeyColUsageColumns(key_col_usage_columns)) == true)
96
121
  {
97
122
    return true;
98
123
  }
99
124
 
 
125
  if ((retval= createOpenTabColumns(open_tab_columns)) == true)
 
126
  {
 
127
    return true;
 
128
  }
 
129
 
100
130
  if ((retval= createPluginsColumns(plugin_columns)) == true)
101
131
  {
102
132
    return true;
112
142
    return true;
113
143
  }
114
144
 
 
145
  if ((retval= createSchemataColumns(schemata_columns)) == true)
 
146
  {
 
147
    return true;
 
148
  }
 
149
 
 
150
  if ((retval= createStatsColumns(stats_columns)) == true)
 
151
  {
 
152
    return true;
 
153
  }
 
154
 
115
155
  if ((retval= createTabConstraintsColumns(tab_constraints_columns)) == true)
116
156
  {
117
157
    return true;
118
158
  }
119
159
 
 
160
  if ((retval= createTablesColumns(tables_columns)) == true)
 
161
  {
 
162
    return true;
 
163
  }
 
164
 
 
165
  if ((retval= createTabNamesColumns(tab_names_columns)) == true)
 
166
  {
 
167
    return true;
 
168
  }
 
169
 
120
170
  return false;
121
171
}
122
172
 
128
178
  clearColumns(char_set_columns);
129
179
  clearColumns(collation_columns);
130
180
  clearColumns(coll_char_columns);
 
181
  clearColumns(col_columns);
131
182
  clearColumns(key_col_usage_columns);
 
183
  clearColumns(open_tab_columns);
132
184
  clearColumns(plugin_columns);
133
185
  clearColumns(processlist_columns);
134
186
  clearColumns(ref_constraint_columns);
 
187
  clearColumns(schemata_columns);
 
188
  clearColumns(stats_columns);
135
189
  clearColumns(tab_constraints_columns);
 
190
  clearColumns(tables_columns);
 
191
  clearColumns(tab_names_columns);
136
192
}
137
193
 
138
194
/**
157
213
    return true;
158
214
  }
159
215
 
 
216
  if ((columns_methods= new(std::nothrow) ColumnsISMethods()) == NULL)
 
217
  {
 
218
    return true;
 
219
  }
 
220
 
160
221
  if ((key_col_usage_methods= new(std::nothrow) KeyColUsageISMethods()) == NULL)
161
222
  {
162
223
    return true;
163
224
  }
164
225
 
 
226
  if ((open_tab_methods= new(std::nothrow) OpenTablesISMethods()) == NULL)
 
227
  {
 
228
    return true;
 
229
  }
 
230
 
165
231
  if ((plugins_methods= new(std::nothrow) PluginsISMethods()) == NULL)
166
232
  {
167
233
    return true;
177
243
    return true;
178
244
  }
179
245
 
 
246
  if ((schemata_methods= new(std::nothrow) SchemataISMethods()) == NULL)
 
247
  {
 
248
    return true;
 
249
  }
 
250
 
 
251
  if ((stats_methods= new(std::nothrow) StatsISMethods()) == NULL)
 
252
  {
 
253
    return true;
 
254
  }
 
255
 
180
256
  if ((tab_constraints_methods= new(std::nothrow) TabConstraintsISMethods()) == NULL)
181
257
  {
182
258
    return true;
183
259
  }
184
260
 
 
261
  if ((tables_methods= new(std::nothrow) TablesISMethods()) == NULL)
 
262
  {
 
263
    return true;
 
264
  }
 
265
 
 
266
  if ((tab_names_methods= new(std::nothrow) TabNamesISMethods()) == NULL)
 
267
  {
 
268
    return true;
 
269
  }
 
270
 
185
271
  return false;
186
272
}
187
273
 
193
279
  delete char_set_methods;
194
280
  delete collation_methods;
195
281
  delete coll_char_methods;
 
282
  delete columns_methods;
196
283
  delete key_col_usage_methods;
 
284
  delete open_tab_methods;
197
285
  delete plugins_methods;
198
286
  delete processlist_methods;
199
287
  delete ref_constraint_methods;
 
288
  delete schemata_methods;
 
289
  delete stats_methods;
200
290
  delete tab_constraints_methods;
 
291
  delete tables_methods;
 
292
  delete tab_names_methods;
201
293
}
202
294
 
203
295
/**
235
327
    return true;
236
328
  }
237
329
 
 
330
  columns_table= new(std::nothrow) InfoSchemaTable("COLUMNS",
 
331
                                                   col_columns,
 
332
                                                   1, 2, false, true,
 
333
                                                   OPTIMIZE_I_S_TABLE,
 
334
                                                   columns_methods);
 
335
  if (columns_table == NULL)
 
336
  {
 
337
    return true;
 
338
  }
 
339
 
238
340
  key_col_usage_table= new(std::nothrow) InfoSchemaTable("KEY_COLUMN_USAGE",
239
341
                                                         key_col_usage_columns,
240
342
                                                         4, 5, false, true,
245
347
    return true;
246
348
  }
247
349
 
 
350
  open_tab_table= new(std::nothrow) InfoSchemaTable("OPEN_TABLES",
 
351
                                                    open_tab_columns,
 
352
                                                    -1, -1, true, false, 0,
 
353
                                                    open_tab_methods);
 
354
  if (open_tab_table == NULL)
 
355
  {
 
356
    return true;
 
357
  }
 
358
 
248
359
  plugins_table= new(std::nothrow) InfoSchemaTable("PLUGINS",
249
360
                                                   plugin_columns,
250
361
                                                   -1, -1, false, false, 0,
273
384
    return true;
274
385
  }
275
386
 
 
387
  schemata_table= new(std::nothrow) InfoSchemaTable("SCHEMATA",
 
388
                                                    schemata_columns,
 
389
                                                    1, -1, false, false, 0,
 
390
                                                    schemata_methods);
 
391
  if (schemata_table == NULL)
 
392
  {
 
393
    return true;
 
394
  }
 
395
 
 
396
  stats_table= new(std::nothrow) InfoSchemaTable("STATISTICS",
 
397
                                                 stats_columns,
 
398
                                                 1, 2, false, true,
 
399
                                                 OPEN_TABLE_ONLY | OPTIMIZE_I_S_TABLE,
 
400
                                                 stats_methods);
 
401
  if (stats_table == NULL)
 
402
  {
 
403
    return true;
 
404
  }
 
405
 
276
406
  tab_constraints_table= new(std::nothrow) InfoSchemaTable("TABLE_CONSTRAINTS",
277
407
                                                           tab_constraints_columns,
278
408
                                                           3, 4, false, true,
283
413
    return true;
284
414
  }
285
415
 
 
416
  tables_table= new(std::nothrow) InfoSchemaTable("TABLES",
 
417
                                                  tables_columns,
 
418
                                                  1, 2, false, true,
 
419
                                                  OPTIMIZE_I_S_TABLE,
 
420
                                                  tables_methods);
 
421
  if (tables_table == NULL)
 
422
  {
 
423
    return true;
 
424
  }
 
425
 
 
426
  tab_names_table= new(std::nothrow) InfoSchemaTable("TABLE_NAMES",
 
427
                                                     tab_names_columns,
 
428
                                                     1, 2, true, true, 0,
 
429
                                                     tab_names_methods);
 
430
  if (tab_names_table == NULL)
 
431
  {
 
432
    return true;
 
433
  }
 
434
 
286
435
  return false;
287
436
}
288
437
 
294
443
  delete char_set_table;
295
444
  delete collation_table;
296
445
  delete coll_char_set_table;
 
446
  delete columns_table;
297
447
  delete key_col_usage_table;
 
448
  delete open_tab_table;
298
449
  delete plugins_table;
299
450
  delete processlist_table;
300
451
  delete ref_constraint_table;
 
452
  delete schemata_table;
 
453
  delete stats_table;
301
454
  delete tab_constraints_table;
 
455
  delete tables_table;
 
456
  delete tab_names_table;
302
457
}
303
458
 
304
459
/**
329
484
  registry.add(char_set_table);
330
485
  registry.add(collation_table);
331
486
  registry.add(coll_char_set_table);
 
487
  registry.add(columns_table);
332
488
  registry.add(key_col_usage_table);
 
489
  registry.add(open_tab_table);
333
490
  registry.add(plugins_table);
334
491
  registry.add(processlist_table);
335
492
  registry.add(ref_constraint_table);
 
493
  registry.add(schemata_table);
 
494
  registry.add(stats_table);
336
495
  registry.add(tab_constraints_table);
 
496
  registry.add(tables_table);
 
497
  registry.add(tab_names_table);
337
498
 
338
499
  return 0;
339
500
}
349
510
  registry.remove(char_set_table);
350
511
  registry.remove(collation_table);
351
512
  registry.remove(coll_char_set_table);
 
513
  registry.remove(columns_table);
352
514
  registry.remove(key_col_usage_table);
 
515
  registry.remove(open_tab_table);
353
516
  registry.remove(plugins_table);
354
517
  registry.remove(processlist_table);
355
518
  registry.remove(ref_constraint_table);
 
519
  registry.remove(schemata_table);
 
520
  registry.remove(stats_table);
356
521
  registry.remove(tab_constraints_table);
 
522
  registry.remove(tables_table);
 
523
  registry.remove(tab_names_table);
357
524
 
358
525
  cleanupTableMethods();
359
526
  cleanupTableColumns();