~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2003 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
1122.2.10 by Monty Taylor
Fixed all of the include guards.
16
#ifndef PLUGIN_ARCHIVE_HA_ARCHIVE_H
17
#define PLUGIN_ARCHIVE_HA_ARCHIVE_H
1 by brian
clean slate
18
19
/*
20
  Please read ha_archive.cc first. If you are looking for more general
21
  answers on how storage engines work, look at ha_example.cc and
22
  ha_example.h.
23
*/
24
1002 by Brian Aker
Refactored out the share to being an object (playing with the structure to
25
class ArchiveShare {
26
public:
27
  ArchiveShare();
28
  ArchiveShare(const char *name);
29
  ~ArchiveShare();
30
31
  bool prime(uint64_t *auto_increment);
32
1093.5.3 by Monty Taylor
Removed using namespace entries from bare headers.
33
  std::string table_name;
1 by brian
clean slate
34
  char data_file_name[FN_REFLEN];
1002 by Brian Aker
Refactored out the share to being an object (playing with the structure to
35
  uint32_t use_count;
1685.2.9 by Brian Aker
Encapsulate the mutex in Archive.
36
  pthread_mutex_t _mutex;
1685.2.5 by Brian Aker
REmove the buffer, and rename lock for privacy
37
  drizzled::THR_LOCK _lock;
1 by brian
clean slate
38
  azio_stream archive_write;     /* Archive file we are working with */
39
  bool archive_write_open;
40
  bool dirty;               /* Flag for if a flush should occur */
41
  bool crashed;             /* Meta file is crashed */
42
  uint64_t mean_rec_length;
43
  char real_path[FN_REFLEN];
1273.12.10 by Monty Taylor
Fix build issues on 32-bit solaris.
44
  uint64_t  version;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
45
  drizzled::ha_rows rows_recorded;    /* Number of rows in tables */
46
  drizzled::ha_rows version_rows;
1685.2.9 by Brian Aker
Encapsulate the mutex in Archive.
47
48
  pthread_mutex_t &mutex()
49
  {
50
    return _mutex;
51
  }
1002 by Brian Aker
Refactored out the share to being an object (playing with the structure to
52
};
1 by brian
clean slate
53
54
/*
55
  Version for file format.
56
  1 - Initial Version (Never Released)
57
  2 - Stream Compression, seperate blobs, no packing
58
  3 - One steam (row and blobs), with packing
59
*/
60
#define ARCHIVE_VERSION 3
61
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
62
class ha_archive: public drizzled::Cursor
1 by brian
clean slate
63
{
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
64
  drizzled::THR_LOCK_DATA lock;        /* MySQL lock */
1002 by Brian Aker
Refactored out the share to being an object (playing with the structure to
65
  ArchiveShare *share;      /* Shared lock info */
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
66
1 by brian
clean slate
67
  azio_stream archive;            /* Archive file we are working with */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
68
  drizzled::internal::my_off_t current_position;  /* The position of the row we just read */
481 by Brian Aker
Remove all of uchar.
69
  unsigned char byte_buffer[IO_SIZE]; /* Initial buffer for our string */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
70
  drizzled::String buffer;             /* Buffer used for blob storage */
71
  drizzled::ha_rows scan_rows;         /* Number of rows left in scan */
1 by brian
clean slate
72
  bool delayed_insert;       /* If the insert is delayed */
73
  bool bulk_insert;          /* If we are performing a bulk insert */
481 by Brian Aker
Remove all of uchar.
74
  const unsigned char *current_key;
482 by Brian Aker
Remove uint.
75
  uint32_t current_key_len;
76
  uint32_t current_k_offset;
1685.2.4 by Brian Aker
Slip to vector for record buffer.
77
  std::vector <unsigned char> record_buffer;
1 by brian
clean slate
78
  bool archive_reader_open;
79
80
public:
1228.1.1 by Monty Taylor
Moved the archive_open_tables list into the Archive Storage Engine itself.
81
  ha_archive(drizzled::plugin::StorageEngine &engine_arg,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
82
             drizzled::TableShare &table_arg);
1 by brian
clean slate
83
  ~ha_archive()
1208.3.2 by brian
Update for Cursor renaming.
84
  { }
1008.3.26 by Stewart Smith
remove handler::table_type() as same information can be retrieved from handler::engine->getName()
85
653 by Brian Aker
More solaris bits
86
  const char *index_type(uint32_t)
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
87
  { return "NONE"; }
653 by Brian Aker
More solaris bits
88
  void get_auto_increment(uint64_t, uint64_t, uint64_t,
89
                          uint64_t *first_value, uint64_t *nb_reserved_values);
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
90
  drizzled::ha_rows records() { return share->rows_recorded; }
1491.1.6 by Jay Pipes
Cursor::ha_index_init() -> Cursor::startIndexScan(). Cursor::ha_index_end() -> Cursor::endIndexScan()
91
  int doStartIndexScan(uint32_t keynr, bool sorted);
481 by Brian Aker
Remove all of uchar.
92
  virtual int index_read(unsigned char * buf, const unsigned char * key,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
93
			 uint32_t key_len,
94
                         drizzled::ha_rkey_function find_flag);
481 by Brian Aker
Remove all of uchar.
95
  int index_next(unsigned char * buf);
1633.4.1 by Brian Aker
Merge ha_open to have doOpen() which passes identifier.
96
  int doOpen(const drizzled::TableIdentifier &identifier, int mode, uint32_t test_if_locked);
482 by Brian Aker
Remove uint.
97
  int open(const char *name, int mode, uint32_t test_if_locked);
1 by brian
clean slate
98
  int close(void);
1491.1.2 by Jay Pipes
Cursor::write_row() -> Cursor::doInsertRecord(). Cursor::ha_write_row() -> Cursor::insertRecord()
99
  int doInsertRecord(unsigned char * buf);
481 by Brian Aker
Remove all of uchar.
100
  int real_write_row(unsigned char *buf, azio_stream *writer);
1 by brian
clean slate
101
  int delete_all_rows();
1491.1.10 by Jay Pipes
ha_rnd_init -> startTableScan, rnd_init -> doStartTableScan, ha_rnd_end -> endTableScan, rnd_end -> doEndTableScan
102
  int doStartTableScan(bool scan=1);
481 by Brian Aker
Remove all of uchar.
103
  int rnd_next(unsigned char *buf);
104
  int rnd_pos(unsigned char * buf, unsigned char *pos);
1002 by Brian Aker
Refactored out the share to being an object (playing with the structure to
105
  ArchiveShare *get_share(const char *table_name, int *rc);
1 by brian
clean slate
106
  int free_share();
107
  int init_archive_writer();
108
  int init_archive_reader();
481 by Brian Aker
Remove all of uchar.
109
  void position(const unsigned char *record);
1 by brian
clean slate
110
  int info(uint);
1222.1.14 by Brian Aker
Remove OPTIMIZE, place in ALTER TABLE (which does the same thing).
111
private:
112
  int get_row(azio_stream *file_to_read, unsigned char *buf);
113
  int get_row_version2(azio_stream *file_to_read, unsigned char *buf);
114
  int get_row_version3(azio_stream *file_to_read, unsigned char *buf);
115
  int read_data_header(azio_stream *file_to_read);
116
  int optimize();
117
  int repair();
118
public:
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
119
  void start_bulk_insert(drizzled::ha_rows rows);
1 by brian
clean slate
120
  int end_bulk_insert();
1638.2.1 by Stewart Smith
remove unused row_type from table proto (although referenced in a bunch of places)
121
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
122
  drizzled::THR_LOCK_DATA **store_lock(drizzled::Session *session,
123
                                       drizzled::THR_LOCK_DATA **to,
124
                                       drizzled::thr_lock_type lock_type);
125
  int check(drizzled::Session* session);
126
  bool check_and_repair(drizzled::Session *session);
481 by Brian Aker
Remove all of uchar.
127
  uint32_t max_row_length(const unsigned char *buf);
1 by brian
clean slate
128
  bool fix_rec_buff(unsigned int length);
481 by Brian Aker
Remove all of uchar.
129
  int unpack_row(azio_stream *file_to_read, unsigned char *record);
130
  unsigned int pack_row(unsigned char *record);
1 by brian
clean slate
131
};
132
1122.2.10 by Monty Taylor
Fixed all of the include guards.
133
#endif /* PLUGIN_ARCHIVE_HA_ARCHIVE_H */