~drizzle-trunk/drizzle/development

1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
1
/* Copyright (C) 2003 MySQL AB
2
   Copyright (C) 2010 Brian Aker
3
4
  This program is free software; you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation; version 2 of the License.
7
8
  This program is distributed in the hope that it will be useful,
9
  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
  GNU General Public License for more details.
12
13
  You should have received a copy of the GNU General Public License
14
  along with this program; if not, write to the Free Software
15
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
16
17
#include "drizzled/field.h"
18
#include "drizzled/field/blob.h"
19
#include "drizzled/field/timestamp.h"
20
#include "plugin/myisam/myisam.h"
21
#include "drizzled/table.h"
22
#include "drizzled/session.h"
23
#include <drizzled/thr_lock.h>
24
#include <drizzled/my_hash.h>
25
#include <drizzled/cursor.h>
26
27
#include <fcntl.h>
28
#include <inttypes.h>
29
#include <string>
30
#include <sys/stat.h>
31
#include <unistd.h>
32
#include <zlib.h>
33
34
#include "azio.h"
35
#include "plugin/archive/ha_archive.h"
36
37
38
39
#include <cstdio>
40
#include <string>
41
#include <map>
42
43
#ifndef PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
44
#define PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
45
46
/* The file extension */
47
#define ARZ ".arz"               // The data file
48
#define ARN ".ARN"               // Files used during an optimize call
49
50
/*
51
  We just implement one additional file extension.
52
*/
53
static const char *ha_archive_exts[] = {
54
  ARZ,
55
  NULL
56
};
57
58
59
class ArchiveEngine : public drizzled::plugin::StorageEngine
60
{
61
  typedef std::map<std::string, ArchiveShare*> ArchiveMap;
62
  ArchiveMap archive_open_tables;
63
64
public:
1358.1.1 by Brian Aker
Fixes regression in performance from Exists patch.
65
  ArchiveEngine() :
66
    drizzled::plugin::StorageEngine("ARCHIVE",
67
                                    drizzled::HTON_STATS_RECORDS_IS_EXACT |
1414 by Brian Aker
Remove dead type.
68
                                    drizzled::HTON_HAS_RECORDS),
1358.1.1 by Brian Aker
Fixes regression in performance from Exists patch.
69
    archive_open_tables()
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
70
  {
71
    table_definition_ext= ARZ;
72
  }
73
74
  virtual drizzled::Cursor *create(drizzled::TableShare &table,
75
                                   drizzled::memory::Root *mem_root)
76
  {
77
    return new (mem_root) ha_archive(*this, table);
78
  }
79
80
  const char **bas_ext() const {
81
    return ha_archive_exts;
82
  }
83
1413 by Brian Aker
doCreateTable() was still taking a pointer instead of a session reference.
84
  int doCreateTable(drizzled::Session &session,
85
                    drizzled::Table &table_arg,
1358.1.2 by Brian Aker
Long pass through the system to use more of TableIdentifiers.
86
                    drizzled::TableIdentifier &identifier,
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
87
                    drizzled::message::Table& proto);
88
89
  int doGetTableDefinition(drizzled::Session& session,
1358.1.2 by Brian Aker
Long pass through the system to use more of TableIdentifiers.
90
                           drizzled::TableIdentifier &identifier,
1354.1.1 by Brian Aker
Modify ptr to reference.
91
                           drizzled::message::Table &table_message);
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
92
1415 by Brian Aker
Mass overhaul to use schema_identifier.
93
  void doGetTableNames(drizzled::CachedDirectory &directory, drizzled::SchemaIdentifier&, std::set<std::string>& set_of_names);
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
94
1358.1.3 by Brian Aker
doDropTable() now only uses identifier.
95
  int doDropTable(drizzled::Session&, drizzled::TableIdentifier &identifier);
1358.1.2 by Brian Aker
Long pass through the system to use more of TableIdentifiers.
96
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
97
  ArchiveShare *findOpenTable(const std::string table_name);
98
  void addOpenTable(const std::string &table_name, ArchiveShare *);
99
  void deleteOpenTable(const std::string &table_name);
100
101
  uint32_t max_supported_keys()          const { return 1; }
102
  uint32_t max_supported_key_length()    const { return sizeof(uint64_t); }
103
  uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
104
105
  uint32_t index_flags(enum  drizzled::ha_key_alg) const
106
  {
107
    return HA_ONLY_WHOLE_INDEX;
108
  }
1358.1.1 by Brian Aker
Fixes regression in performance from Exists patch.
109
110
  bool doDoesTableExist(drizzled::Session&, drizzled::TableIdentifier &identifier);
1390 by Brian Aker
Update interface to use Identifiers directly.
111
  int doRenameTable(drizzled::Session&, drizzled::TableIdentifier &from, drizzled::TableIdentifier &to);
1429.1.3 by Brian Aker
Merge in work for fetching a list of table identifiers.
112
113
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
114
                             drizzled::SchemaIdentifier &schema_identifier,
115
                             drizzled::TableIdentifiers &set_of_identifiers);
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
116
};
117
118
#endif /* PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H */