1
/* Copyright (C) 2005 MySQL AB
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.
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.
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 */
16
#include <plugin/information_engine/information_engine.h>
17
#include <drizzled/plugin/info_schema_table.h>
21
static const string engine_name("INFORMATION_ENGINE");
23
/*****************************************************************************
24
** INFORMATION_ENGINE tables
25
*****************************************************************************/
27
InformationCursor::InformationCursor(drizzled::plugin::StorageEngine *engine_arg,
28
TableShare *table_arg) :
29
Cursor(engine_arg, table_arg)
32
uint32_t InformationCursor::index_flags(uint32_t, uint32_t, bool) const
37
int InformationCursor::open(const char *name, int, uint32_t)
39
InformationShare *shareable;
41
if (!(shareable= InformationShare::get(name)))
42
return(HA_ERR_OUT_OF_MEM);
44
thr_lock_data_init(&shareable->lock, &lock, NULL);
49
int InformationCursor::close(void)
51
InformationShare::free(share);
56
void InformationEngine::doGetTableNames(CachedDirectory&, string& db, set<string>& set_of_names)
58
if (db.compare("information_schema"))
61
drizzled::plugin::InfoSchemaTable::getTableNames(set_of_names);
66
int InformationCursor::rnd_init(bool)
72
int InformationCursor::rnd_next(unsigned char *)
74
return HA_ERR_END_OF_FILE;
78
int InformationCursor::rnd_pos(unsigned char *, unsigned char *)
86
void InformationCursor::position(const unsigned char *)
92
int InformationCursor::info(uint32_t flag)
94
memset(&stats, 0, sizeof(stats));
95
if (flag & HA_STATUS_AUTO)
96
stats.auto_increment_value= 1;
101
THR_LOCK_DATA **InformationCursor::store_lock(Session *session,
103
enum thr_lock_type lock_type)
105
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
108
Here is where we get into the guts of a row level lock.
110
If we are not doing a LOCK Table or DISCARD/IMPORT
111
TABLESPACE, then allow multiple writers
114
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
115
lock_type <= TL_WRITE) && !session_tablespace_op(session))
116
lock_type = TL_WRITE_ALLOW_WRITE;
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.
126
if (lock_type == TL_READ_NO_INSERT)
129
lock.type= lock_type;
136
static drizzled::plugin::StorageEngine *information_engine= NULL;
138
static int init(drizzled::plugin::Registry ®istry)
140
information_engine= new InformationEngine(engine_name);
141
registry.add(information_engine);
143
InformationShare::start();
148
static int finalize(drizzled::plugin::Registry ®istry)
150
registry.remove(information_engine);
151
delete information_engine;
153
InformationShare::stop();
158
drizzle_declare_plugin(information_engine)
160
"INFORMATION_ENGINE",
162
"Sun Microsystems ala Brian Aker",
163
"Engine which provides information schema tables",
165
init, /* Plugin Init */
166
finalize, /* Plugin Deinit */
167
NULL, /* status variables */
168
NULL, /* system variables */
169
NULL /* config options */
171
drizzle_declare_plugin_end;