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 "information_engine.h"
17
#include <drizzled/table.h>
23
static const string engine_name("INFORMATION_ENGINE");
25
/*****************************************************************************
26
** INFORMATION_ENGINE tables
27
*****************************************************************************/
29
InformationCursor::InformationCursor(drizzled::plugin::StorageEngine *engine_arg,
30
TableShare *table_arg) :
31
handler(engine_arg, table_arg)
34
uint32_t InformationCursor::index_flags(uint32_t, uint32_t, bool) const
39
int InformationCursor::open(const char *name, int, uint32_t)
41
InformationShare *shareable;
43
if (!(shareable= InformationShare::get(name)))
44
return(HA_ERR_OUT_OF_MEM);
46
thr_lock_data_init(&shareable->lock, &lock, NULL);
51
int InformationCursor::close(void)
53
InformationShare::free(share);
58
int InformationEngine::createTableImplementation(Session*, const char *,
59
Table *, HA_CREATE_INFO *,
60
drizzled::message::Table*)
65
int InformationEngine::deleteTableImplementation(Session*, const string)
70
int InformationCursor::write_row(unsigned char *)
72
return(table->next_number_field ? update_auto_increment() : 0);
75
int InformationCursor::rnd_init(bool)
81
int InformationCursor::rnd_next(unsigned char *)
83
return HA_ERR_END_OF_FILE;
87
int InformationCursor::rnd_pos(unsigned char *, unsigned char *)
95
void InformationCursor::position(const unsigned char *)
101
int InformationCursor::info(uint32_t flag)
103
memset(&stats, 0, sizeof(stats));
104
if (flag & HA_STATUS_AUTO)
105
stats.auto_increment_value= 1;
109
int InformationCursor::external_lock(Session *, int)
115
THR_LOCK_DATA **InformationCursor::store_lock(Session *session,
117
enum thr_lock_type lock_type)
119
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
122
Here is where we get into the guts of a row level lock.
124
If we are not doing a LOCK Table or DISCARD/IMPORT
125
TABLESPACE, then allow multiple writers
128
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
129
lock_type <= TL_WRITE) && !session_tablespace_op(session))
130
lock_type = TL_WRITE_ALLOW_WRITE;
133
In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
134
MySQL would use the lock TL_READ_NO_INSERT on t2, and that
135
would conflict with TL_WRITE_ALLOW_WRITE, blocking all inserts
136
to t2. Convert the lock to a normal read lock to allow
137
concurrent inserts to t2.
140
if (lock_type == TL_READ_NO_INSERT)
143
lock.type= lock_type;
150
static drizzled::plugin::StorageEngine *information_engine= NULL;
152
static int init(drizzled::plugin::Registry ®istry)
155
information_engine= new InformationEngine(engine_name);
156
registry.add(information_engine);
158
InformationShare::start();
163
static int finalize(drizzled::plugin::Registry ®istry)
165
registry.remove(information_engine);
166
delete information_engine;
168
InformationShare::stop();
173
drizzle_declare_plugin(information_engine)
175
"INFORMATION_ENGINE",
177
"Sun Microsystems ala Brian Aker",
178
"Engine which provides information schema tables",
180
init, /* Plugin Init */
181
finalize, /* Plugin Deinit */
182
NULL, /* status variables */
183
NULL, /* system variables */
184
NULL /* config options */
186
drizzle_declare_plugin_end;