~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/structs.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
/* The old structures from unireg */
 
22
 
 
23
#ifndef DRIZZLED_STRUCTS_H
 
24
#define DRIZZLED_STRUCTS_H
 
25
 
 
26
#include "drizzled/base.h"
 
27
#include "drizzled/definitions.h"
 
28
#include "drizzled/lex_string.h"
 
29
#include "drizzled/thr_lock.h"
 
30
 
 
31
namespace drizzled
 
32
{
 
33
 
 
34
namespace internal
 
35
{
 
36
typedef struct st_io_cache IO_CACHE;
 
37
}
 
38
 
 
39
class Table;
 
40
class Field;
 
41
 
 
42
typedef struct st_keyfile_info {        /* used with ha_info() */
 
43
  unsigned char ref[MAX_REFLENGTH];             /* Pointer to current row */
 
44
  unsigned char dupp_ref[MAX_REFLENGTH];        /* Pointer to dupp row */
 
45
  uint32_t ref_length;                  /* Length of ref (1-8) */
 
46
  uint32_t block_size;                  /* index block size */
 
47
  int filenr;                           /* (uniq) filenr for table */
 
48
  ha_rows records;                      /* Records i datafilen */
 
49
  ha_rows deleted;                      /* Deleted records */
 
50
  uint64_t data_file_length;            /* Length off data file */
 
51
  uint64_t max_data_file_length;        /* Length off data file */
 
52
  uint64_t index_file_length;
 
53
  uint64_t max_index_file_length;
 
54
  uint64_t delete_length;               /* Free bytes */
 
55
  uint64_t auto_increment_value;
 
56
  int errkey,sortkey;                   /* Last errorkey and sorted by */
 
57
  time_t create_time;                   /* When table was created */
 
58
  time_t check_time;
 
59
  time_t update_time;
 
60
  uint64_t mean_rec_length;             /* physical reclength */
 
61
} KEYFILE_INFO;
 
62
 
 
63
 
 
64
typedef struct st_key_part_info {       /* Info about a key part */
 
65
  Field *field;
 
66
  unsigned int  offset;                         /* offset in record (from 0) */
 
67
  unsigned int  null_offset;                    /* Offset to null_bit in record */
 
68
  /* Length of key part in bytes, excluding NULL flag and length bytes */
 
69
  uint16_t length;
 
70
  /*
 
71
    Number of bytes required to store the keypart value. This may be
 
72
    different from the "length" field as it also counts
 
73
     - possible NULL-flag byte (see HA_KEY_NULL_LENGTH) [if null_bit != 0,
 
74
       the first byte stored at offset is 1 if null, 0 if non-null; the
 
75
       actual value is stored from offset+1].
 
76
     - possible HA_KEY_BLOB_LENGTH bytes needed to store actual value length.
 
77
  */
 
78
  uint16_t store_length;
 
79
  uint16_t key_type;
 
80
  uint16_t fieldnr;                     /* Fieldnum in UNIREG (1,2,3,...) */
 
81
  uint16_t key_part_flag;                       /* 0 or HA_REVERSE_SORT */
 
82
  uint8_t type;
 
83
  uint8_t null_bit;                     /* Position to null_bit */
 
84
} KEY_PART_INFO ;
 
85
 
 
86
 
 
87
typedef struct st_key {
 
88
  unsigned int  key_length;             /* Tot length of key */
 
89
  enum  ha_key_alg algorithm;
 
90
  unsigned long flags;                  /* dupp key and pack flags */
 
91
  unsigned int key_parts;               /* How many key_parts */
 
92
  uint32_t  extra_length;
 
93
  unsigned int usable_key_parts;        /* Should normally be = key_parts */
 
94
  uint32_t  block_size;
 
95
  KEY_PART_INFO *key_part;
 
96
  char  *name;                          /* Name of key */
 
97
  /*
 
98
    Array of AVG(#records with the same field value) for 1st ... Nth key part.
 
99
    0 means 'not known'.
 
100
    For temporary heap tables this member is NULL.
 
101
  */
 
102
  ulong *rec_per_key;
 
103
  Table *table;
 
104
  LEX_STRING comment;
 
105
} KEY;
 
106
 
 
107
 
 
108
class JoinTable;
 
109
 
 
110
struct RegInfo {                /* Extra info about reg */
 
111
  JoinTable *join_tab;  /* Used by SELECT() */
 
112
  enum thr_lock_type lock_type;         /* How database is used */
 
113
  bool not_exists_optimize;
 
114
  bool impossible_range;
 
115
  RegInfo()
 
116
    : join_tab(NULL), lock_type(TL_UNLOCK),
 
117
      not_exists_optimize(false), impossible_range(false) {}
 
118
  void reset()
 
119
  {
 
120
    join_tab= NULL;
 
121
    lock_type= TL_UNLOCK;
 
122
    not_exists_optimize= false;
 
123
    impossible_range= false;
 
124
  }
 
125
};
 
126
 
 
127
struct st_read_record;                          /* For referense later */
 
128
class Session;
 
129
class Cursor;
 
130
namespace optimizer { class SqlSelect; }
 
131
 
 
132
typedef struct st_read_record {                 /* Parameter to read_record */
 
133
  Table *table;                 /* Head-form */
 
134
  Cursor *cursor;
 
135
  Table **forms;                        /* head and ref forms */
 
136
  int (*read_record)(struct st_read_record *);
 
137
  Session *session;
 
138
  optimizer::SqlSelect *select;
 
139
  uint32_t cache_records;
 
140
  uint32_t ref_length,struct_length,reclength,rec_cache_size,error_offset;
 
141
  uint32_t index;
 
142
  unsigned char *ref_pos;                               /* pointer to form->refpos */
 
143
  unsigned char *record;
 
144
  unsigned char *rec_buf;                /* to read field values  after filesort */
 
145
  unsigned char *cache,*cache_pos,*cache_end,*read_positions;
 
146
  internal::IO_CACHE *io_cache;
 
147
  bool print_error, ignore_not_found_rows;
 
148
  JoinTable *do_insideout_scan;
 
149
} READ_RECORD;
 
150
 
 
151
typedef int *(*update_var)(Session *, struct drizzle_show_var *);
 
152
 
 
153
} /* namespace drizzled */
 
154
 
 
155
        /* Bits in form->status */
 
156
#define STATUS_NO_RECORD        (1+2)   /* Record isn't usably */
 
157
#define STATUS_GARBAGE          1
 
158
#define STATUS_NOT_FOUND        2       /* No record in database when needed */
 
159
#define STATUS_NO_PARENT        4       /* Parent record wasn't found */
 
160
#define STATUS_NOT_READ         8       /* Record isn't read */
 
161
#define STATUS_UPDATED          16      /* Record is updated by formula */
 
162
#define STATUS_NULL_ROW         32      /* table->null_row is set */
 
163
#define STATUS_DELETED          64
 
164
 
 
165
#endif /* DRIZZLED_STRUCTS_H */