~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/information_engine/information_engine.cc

Added code necessary for building plugins dynamically.
Merged in changes from lifeless to allow autoreconf to work.
Touching plugin.ini files now triggers a rebuid - so config/autorun.sh is no
longer required to be run after touching those.
Removed the duplicate plugin names - also removed the issue that getting them
different would silently fail weirdly later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2005 MySQL AB
 
2
 
 
3
  This program is free software; you can redistribute it and/or modify
 
4
  it under the terms of the GNU General Public License as published by
 
5
  the Free Software Foundation; version 2 of the License.
 
6
 
 
7
  This program is distributed in the hope that it will be useful,
 
8
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
  GNU General Public License for more details.
 
11
 
 
12
  You should have received a copy of the GNU General Public License
 
13
  along with this program; if not, write to the Free Software
 
14
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include <plugin/information_engine/information_engine.h>
 
17
#include <drizzled/plugin/info_schema_table.h>
 
18
 
 
19
using namespace std;
 
20
 
 
21
static const string engine_name("INFORMATION_ENGINE");
 
22
 
 
23
/*****************************************************************************
 
24
** INFORMATION_ENGINE tables
 
25
*****************************************************************************/
 
26
 
 
27
InformationCursor::InformationCursor(drizzled::plugin::StorageEngine *engine_arg,
 
28
                                     TableShare *table_arg) :
 
29
  Cursor(engine_arg, table_arg)
 
30
{}
 
31
 
 
32
uint32_t InformationCursor::index_flags(uint32_t, uint32_t, bool) const
 
33
{
 
34
  return 0;
 
35
}
 
36
 
 
37
int InformationCursor::open(const char *name, int, uint32_t)
 
38
{
 
39
  InformationShare *shareable;
 
40
 
 
41
  if (!(shareable= InformationShare::get(name)))
 
42
    return(HA_ERR_OUT_OF_MEM);
 
43
 
 
44
  thr_lock_data_init(&shareable->lock, &lock, NULL);
 
45
 
 
46
  return 0;
 
47
}
 
48
 
 
49
int InformationCursor::close(void)
 
50
{
 
51
  InformationShare::free(share);
 
52
 
 
53
  return 0;
 
54
}
 
55
 
 
56
void InformationEngine::doGetTableNames(CachedDirectory&, string& db, set<string>& set_of_names)
 
57
{
 
58
  if (db.compare("information_schema"))
 
59
    return;
 
60
 
 
61
  drizzled::plugin::InfoSchemaTable::getTableNames(set_of_names);
 
62
}
 
63
 
 
64
 
 
65
 
 
66
int InformationCursor::rnd_init(bool)
 
67
{
 
68
  return 0;
 
69
}
 
70
 
 
71
 
 
72
int InformationCursor::rnd_next(unsigned char *)
 
73
{
 
74
  return HA_ERR_END_OF_FILE;
 
75
}
 
76
 
 
77
 
 
78
int InformationCursor::rnd_pos(unsigned char *, unsigned char *)
 
79
{
 
80
  assert(1);
 
81
 
 
82
  return 0;
 
83
}
 
84
 
 
85
 
 
86
void InformationCursor::position(const unsigned char *)
 
87
{
 
88
  assert(1);
 
89
}
 
90
 
 
91
 
 
92
int InformationCursor::info(uint32_t flag)
 
93
{
 
94
  memset(&stats, 0, sizeof(stats));
 
95
  if (flag & HA_STATUS_AUTO)
 
96
    stats.auto_increment_value= 1;
 
97
  return(0);
 
98
}
 
99
 
 
100
 
 
101
THR_LOCK_DATA **InformationCursor::store_lock(Session *session,
 
102
                                         THR_LOCK_DATA **to,
 
103
                                         enum thr_lock_type lock_type)
 
104
{
 
105
  if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
 
106
  {
 
107
    /*
 
108
      Here is where we get into the guts of a row level lock.
 
109
      If TL_UNLOCK is set
 
110
      If we are not doing a LOCK Table or DISCARD/IMPORT
 
111
      TABLESPACE, then allow multiple writers
 
112
    */
 
113
 
 
114
    if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
 
115
         lock_type <= TL_WRITE) && !session_tablespace_op(session))
 
116
      lock_type = TL_WRITE_ALLOW_WRITE;
 
117
 
 
118
    /*
 
119
      In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
 
120
      MySQL would use the lock TL_READ_NO_INSERT on t2, and that
 
121
      would conflict with TL_WRITE_ALLOW_WRITE, blocking all inserts
 
122
      to t2. Convert the lock to a normal read lock to allow
 
123
      concurrent inserts to t2.
 
124
    */
 
125
 
 
126
    if (lock_type == TL_READ_NO_INSERT)
 
127
      lock_type = TL_READ;
 
128
 
 
129
    lock.type= lock_type;
 
130
  }
 
131
  *to++= &lock;
 
132
 
 
133
  return to;
 
134
}
 
135
 
 
136
static drizzled::plugin::StorageEngine *information_engine= NULL;
 
137
 
 
138
static int init(drizzled::plugin::Registry &registry)
 
139
{
 
140
  information_engine= new InformationEngine(engine_name);
 
141
  registry.add(information_engine);
 
142
  
 
143
  InformationShare::start();
 
144
 
 
145
  return 0;
 
146
}
 
147
 
 
148
static int finalize(drizzled::plugin::Registry &registry)
 
149
{
 
150
  registry.remove(information_engine);
 
151
  delete information_engine;
 
152
 
 
153
  InformationShare::stop();
 
154
 
 
155
  return 0;
 
156
}
 
157
 
 
158
drizzle_declare_plugin
 
159
{
 
160
  "INFORMATION_ENGINE",
 
161
  "1.0",
 
162
  "Sun Microsystems ala Brian Aker",
 
163
  "Engine which provides information schema tables",
 
164
  PLUGIN_LICENSE_GPL,
 
165
  init,     /* Plugin Init */
 
166
  finalize,     /* Plugin Deinit */
 
167
  NULL,               /* status variables */
 
168
  NULL,               /* system variables */
 
169
  NULL                /* config options   */
 
170
}
 
171
drizzle_declare_plugin_end;