~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/information_engine/information_engine.h

  • Committer: Brian Aker
  • Date: 2009-10-15 00:22:33 UTC
  • mto: (1183.1.11 merge)
  • mto: This revision was merged to the branch mainline in revision 1198.
  • Revision ID: brian@gaz-20091015002233-fa4ao2mbc67wls91
First pass of information engine. OMG, ponies... is it so much easier to
deal with creating and engine.

The list table iterator though... its ass, needs to go. We should also
abstract out share. Very few engines need a custom one. Just say'in

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
 
 
17
#ifndef PLUGIN_INFORMATION_ENGINE_HA_INFORMATION_ENGINE_H
 
18
#define PLUGIN_INFORMATION_ENGINE_HA_INFORMATION_ENGINE_H
 
19
 
 
20
#include <drizzled/server_includes.h>
 
21
#include <drizzled/handler.h>
 
22
#include <mysys/thr_lock.h>
 
23
#include "information_share.h"
 
24
 
 
25
 
 
26
/*
 
27
  Class definition for the information engine
 
28
*/
 
29
class InformationCursor: public handler
 
30
{
 
31
  THR_LOCK_DATA lock;      /* MySQL lock */
 
32
  InformationShare *share;
 
33
 
 
34
public:
 
35
  InformationCursor(drizzled::plugin::StorageEngine *engine, TableShare *table_arg);
 
36
  ~InformationCursor()
 
37
  {}
 
38
 
 
39
  /*
 
40
    The name of the index type that will be used for display
 
41
    don't implement this method unless you really have indexes
 
42
  */
 
43
  uint64_t table_flags() const
 
44
  {
 
45
    return 0;
 
46
  }
 
47
  uint32_t index_flags(uint32_t inx, uint32_t part, bool all_parts) const;
 
48
  /* The following defines can be increased if necessary */
 
49
  int open(const char *name, int mode, uint32_t test_if_locked);
 
50
  int close(void);
 
51
  int write_row(unsigned char * buf);
 
52
  int rnd_init(bool scan);
 
53
  int rnd_next(unsigned char *buf);
 
54
  int rnd_pos(unsigned char * buf, unsigned char *pos);
 
55
  void position(const unsigned char *record);
 
56
  int info(uint32_t flag);
 
57
  int external_lock(Session *session, int lock_type);
 
58
  THR_LOCK_DATA **store_lock(Session *session,
 
59
                             THR_LOCK_DATA **to,
 
60
                             enum thr_lock_type lock_type);
 
61
};
 
62
 
 
63
static const char *InformationEngine_exts[] = {
 
64
  NULL
 
65
};
 
66
 
 
67
class InformationEngineNameIterator: public drizzled::plugin::TableNameIteratorImplementation
 
68
{
 
69
public:
 
70
  InformationEngineNameIterator(const std::string &database)
 
71
    : drizzled::plugin::TableNameIteratorImplementation(database)
 
72
    {};
 
73
 
 
74
  int next(std::string *)
 
75
  {
 
76
    return 1;
 
77
  }
 
78
 
 
79
};
 
80
 
 
81
class InformationEngine : public drizzled::plugin::StorageEngine
 
82
{
 
83
public:
 
84
  InformationEngine(const string &name_arg)
 
85
   : drizzled::plugin::StorageEngine(name_arg,
 
86
                                     HTON_FILE_BASED
 
87
                                      | HTON_HAS_DATA_DICTIONARY) {}
 
88
  virtual handler *create(TableShare *table, MEM_ROOT *mem_root)
 
89
  {
 
90
    return new (mem_root) InformationCursor(this, table);
 
91
  }
 
92
 
 
93
  const char **bas_ext() const {
 
94
    return InformationEngine_exts;
 
95
  }
 
96
 
 
97
  int createTableImplementation(Session*, const char *, Table *,
 
98
                                HA_CREATE_INFO *, drizzled::message::Table*);
 
99
 
 
100
  int deleteTableImplementation(Session*, const string table_name); 
 
101
 
 
102
  drizzled::plugin::TableNameIteratorImplementation* tableNameIterator(const std::string &database)
 
103
  {
 
104
    return new InformationEngineNameIterator(database);
 
105
  }
 
106
};
 
107
 
 
108
#endif /* PLUGIN_INFORMATION_ENGINE_HA_INFORMATION_ENGINE_H */