~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/ha_archive.h

  • Committer: Monty Taylor
  • Date: 2008-07-05 22:08:52 UTC
  • mto: This revision was merged to the branch mainline in revision 77.
  • Revision ID: monty@inaugust.com-20080705220852-cqd9t6tfkhvlcf73
Removed HAVE_LONG_LONG, as this is now assumed.

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