~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/info_schema/helper_methods.cc

  • Committer: Brian Aker
  • Date: 2010-02-19 23:07:45 UTC
  • mto: (1273.13.97 build)
  • mto: This revision was merged to the branch mainline in revision 1309.
  • Revision ID: brian@gaz-20100219230745-cmurfbxj845it9z7
This remove the original info_schema system for the server. More still to
cut, but we are on our way.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
/**
22
 
 * @file 
23
 
 *   Implementation of helper methods for I_S tables.
24
 
 */
25
 
 
26
 
#include "config.h"
27
 
#include "drizzled/session.h"
28
 
#include "drizzled/show.h"
29
 
#include "drizzled/sql_base.h"
30
 
#include "drizzled/plugin/client.h"
31
 
#include "drizzled/join_table.h"
32
 
#include "drizzled/global_charset_info.h"
33
 
#include "drizzled/pthread_globals.h"
34
 
#include "drizzled/internal/m_string.h"
35
 
#include "plugin/myisam/myisam.h" // needed for dflt_key_cache
36
 
#include "helper_methods.h"
37
 
 
38
 
#include <vector>
39
 
#include <string>
40
 
#include <sstream>
41
 
 
42
 
using namespace std;
43
 
using namespace drizzled;
44
 
 
45
 
static inline void make_upper(char *buf)
46
 
{
47
 
  for (; *buf; buf++)
48
 
    *buf= my_toupper(system_charset_info, *buf);
49
 
}
50
 
 
51
 
void store_key_column_usage(Table *table, 
52
 
                            LEX_STRING *db_name,
53
 
                            LEX_STRING *table_name, 
54
 
                            const char *key_name,
55
 
                            uint32_t key_len, 
56
 
                            const char *con_type, 
57
 
                            uint32_t con_len,
58
 
                            int64_t idx)
59
 
{
60
 
  const CHARSET_INFO * const cs= system_charset_info;
61
 
  /* set the appropriate bits in the write bitset */
62
 
  table->setWriteSet(1);
63
 
  table->setWriteSet(2);
64
 
  table->setWriteSet(4);
65
 
  table->setWriteSet(5);
66
 
  table->setWriteSet(6);
67
 
  table->setWriteSet(7);
68
 
  table->field[1]->store(db_name->str, db_name->length, cs);
69
 
  table->field[2]->store(key_name, key_len, cs);
70
 
  table->field[4]->store(db_name->str, db_name->length, cs);
71
 
  table->field[5]->store(table_name->str, table_name->length, cs);
72
 
  table->field[6]->store(con_type, con_len, cs);
73
 
  table->field[7]->store((int64_t) idx, true);
74
 
}
75
 
 
76
 
/*
77
 
 * Function object used for deleting the memory allocated
78
 
 * for the columns contained with the vector of columns.
79
 
 */
80
 
class DeleteColumns
81
 
{
82
 
public:
83
 
  template<typename T>
84
 
  inline void operator()(const T *ptr) const
85
 
  {
86
 
    delete ptr;
87
 
  }
88
 
};
89
 
 
90
 
void clearColumns(vector<const drizzled::plugin::ColumnInfo *> &cols)
91
 
{
92
 
  for_each(cols.begin(), cols.end(), DeleteColumns());
93
 
  cols.clear();
94
 
}