~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/ha_archive.h

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
  along with this program; if not, write to the Free Software
14
14
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#ifdef USE_PRAGMA_INTERFACE
17
 
#pragma interface                       /* gcc class implementation */
18
 
#endif
19
16
 
20
17
#include <inttypes.h>
21
18
#include <zlib.h>
22
19
#include "azio.h"
 
20
#include <mysys/thr_lock.h>
23
21
 
24
22
/*
25
23
  Please read ha_archive.cc first. If you are looking for more general
28
26
*/
29
27
 
30
28
typedef struct st_archive_record_buffer {
31
 
  uchar *buffer;
 
29
  unsigned char *buffer;
32
30
  uint32_t length;
33
31
} archive_record_buffer;
34
32
 
36
34
typedef struct st_archive_share {
37
35
  char *table_name;
38
36
  char data_file_name[FN_REFLEN];
39
 
  uint table_name_length,use_count;
 
37
  uint32_t table_name_length,use_count;
40
38
  pthread_mutex_t mutex;
41
39
  THR_LOCK lock;
42
40
  azio_stream archive_write;     /* Archive file we are working with */
65
63
  
66
64
  azio_stream archive;            /* Archive file we are working with */
67
65
  my_off_t current_position;  /* The position of the row we just read */
68
 
  uchar byte_buffer[IO_SIZE]; /* Initial buffer for our string */
 
66
  unsigned char byte_buffer[IO_SIZE]; /* Initial buffer for our string */
69
67
  String buffer;             /* Buffer used for blob storage */
70
68
  ha_rows scan_rows;         /* Number of rows left in scan */
71
69
  bool delayed_insert;       /* If the insert is delayed */
72
70
  bool bulk_insert;          /* If we are performing a bulk insert */
73
 
  const uchar *current_key;
74
 
  uint current_key_len;
75
 
  uint current_k_offset;
 
71
  const unsigned char *current_key;
 
72
  uint32_t current_key_len;
 
73
  uint32_t current_k_offset;
76
74
  archive_record_buffer *record_buffer;
77
75
  bool archive_reader_open;
78
76
 
85
83
  {
86
84
  }
87
85
  const char *table_type() const { return "ARCHIVE"; }
88
 
  const char *index_type(uint inx __attribute__((unused)))
 
86
  const char *index_type(uint32_t inx __attribute__((unused)))
89
87
  { return "NONE"; }
90
88
  const char **bas_ext() const;
91
89
  uint64_t table_flags() const
92
90
  {
93
 
    return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_CAN_BIT_FIELD |
 
91
    return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ |
94
92
            HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
95
93
            HA_STATS_RECORDS_IS_EXACT |
96
94
            HA_HAS_RECORDS |
97
 
            HA_FILE_BASED | HA_CAN_INSERT_DELAYED | HA_CAN_GEOMETRY);
 
95
            HA_FILE_BASED);
98
96
  }
99
 
  uint32_t index_flags(uint idx __attribute__((unused)),
100
 
                       uint part __attribute__((unused)),
 
97
  uint32_t index_flags(uint32_t idx __attribute__((unused)),
 
98
                       uint32_t part __attribute__((unused)),
101
99
                       bool all_parts __attribute__((unused))) const
102
100
  {
103
101
    return HA_ONLY_WHOLE_INDEX;
106
104
                                  uint64_t nb_desired_values,
107
105
                                  uint64_t *first_value,
108
106
                                  uint64_t *nb_reserved_values);
109
 
  uint max_supported_keys()          const { return 1; }
110
 
  uint max_supported_key_length()    const { return sizeof(uint64_t); }
111
 
  uint max_supported_key_part_length() const { return sizeof(uint64_t); }
 
107
  uint32_t max_supported_keys()          const { return 1; }
 
108
  uint32_t max_supported_key_length()    const { return sizeof(uint64_t); }
 
109
  uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
112
110
  ha_rows records() { return share->rows_recorded; }
113
 
  int index_init(uint keynr, bool sorted);
114
 
  virtual int index_read(uchar * buf, const uchar * key,
115
 
                         uint key_len, enum ha_rkey_function find_flag);
116
 
  virtual int index_read_idx(uchar * buf, uint index, const uchar * key,
117
 
                             uint key_len, enum ha_rkey_function find_flag);
118
 
  int index_next(uchar * buf);
119
 
  int open(const char *name, int mode, uint test_if_locked);
 
111
  int index_init(uint32_t keynr, bool sorted);
 
112
  virtual int index_read(unsigned char * buf, const unsigned char * key,
 
113
                         uint32_t key_len, enum ha_rkey_function find_flag);
 
114
  virtual int index_read_idx(unsigned char * buf, uint32_t index, const unsigned char * key,
 
115
                             uint32_t key_len, enum ha_rkey_function find_flag);
 
116
  int index_next(unsigned char * buf);
 
117
  int open(const char *name, int mode, uint32_t test_if_locked);
120
118
  int close(void);
121
 
  int write_row(uchar * buf);
122
 
  int real_write_row(uchar *buf, azio_stream *writer);
 
119
  int write_row(unsigned char * buf);
 
120
  int real_write_row(unsigned char *buf, azio_stream *writer);
123
121
  int delete_all_rows();
124
122
  int rnd_init(bool scan=1);
125
 
  int rnd_next(uchar *buf);
126
 
  int rnd_pos(uchar * buf, uchar *pos);
127
 
  int get_row(azio_stream *file_to_read, uchar *buf);
128
 
  int get_row_version2(azio_stream *file_to_read, uchar *buf);
129
 
  int get_row_version3(azio_stream *file_to_read, uchar *buf);
 
123
  int rnd_next(unsigned char *buf);
 
124
  int rnd_pos(unsigned char * buf, unsigned char *pos);
 
125
  int get_row(azio_stream *file_to_read, unsigned char *buf);
 
126
  int get_row_version2(azio_stream *file_to_read, unsigned char *buf);
 
127
  int get_row_version3(azio_stream *file_to_read, unsigned char *buf);
130
128
  ARCHIVE_SHARE *get_share(const char *table_name, int *rc);
131
129
  int free_share();
132
130
  int init_archive_writer();
133
131
  int init_archive_reader();
134
132
  bool auto_repair() const { return 1; } // For the moment we just do this
135
133
  int read_data_header(azio_stream *file_to_read);
136
 
  void position(const uchar *record);
 
134
  void position(const unsigned char *record);
137
135
  int info(uint);
138
136
  void update_create_info(HA_CREATE_INFO *create_info);
139
137
  int create(const char *name, Table *form, HA_CREATE_INFO *create_info);
140
 
  int optimize(THD* thd, HA_CHECK_OPT* check_opt);
141
 
  int repair(THD* thd, HA_CHECK_OPT* check_opt);
 
138
  int optimize(Session* session, HA_CHECK_OPT* check_opt);
 
139
  int repair(Session* session, HA_CHECK_OPT* check_opt);
142
140
  void start_bulk_insert(ha_rows rows);
143
141
  int end_bulk_insert();
144
142
  enum row_type get_row_type() const 
145
143
  { 
146
144
    return ROW_TYPE_COMPRESSED;
147
145
  }
148
 
  THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
 
146
  THR_LOCK_DATA **store_lock(Session *session, THR_LOCK_DATA **to,
149
147
                             enum thr_lock_type lock_type);
150
148
  bool is_crashed() const;
151
 
  int check(THD* thd, HA_CHECK_OPT* check_opt);
152
 
  bool check_and_repair(THD *thd);
153
 
  uint32_t max_row_length(const uchar *buf);
 
149
  int check(Session* session, HA_CHECK_OPT* check_opt);
 
150
  bool check_and_repair(Session *session);
 
151
  uint32_t max_row_length(const unsigned char *buf);
154
152
  bool fix_rec_buff(unsigned int length);
155
 
  int unpack_row(azio_stream *file_to_read, uchar *record);
156
 
  unsigned int pack_row(uchar *record);
 
153
  int unpack_row(azio_stream *file_to_read, unsigned char *record);
 
154
  unsigned int pack_row(unsigned char *record);
157
155
};
158
156