Drizzled Public API Documentation

structs.h

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 /* The old structures from unireg */
00022 
00023 #pragma once
00024 
00025 #include <drizzled/base.h>
00026 #include <drizzled/definitions.h>
00027 #include <drizzled/lex_string.h>
00028 #include <drizzled/thr_lock.h>
00029 
00030 namespace drizzled
00031 {
00032 
00033 namespace internal
00034 {
00035 typedef struct st_io_cache IO_CACHE;
00036 }
00037 
00038 class Table;
00039 class Field;
00040 
00041 class KeyPartInfo 
00042 { /* Info about a key part */
00043 public:
00044   Field *field;
00045   unsigned int  offset;       /* offset in record (from 0) */
00046   unsigned int  null_offset;      /* Offset to null_bit in record */
00047   /* Length of key part in bytes, excluding NULL flag and length bytes */
00048   uint16_t length;
00049   /*
00050     Number of bytes required to store the keypart value. This may be
00051     different from the "length" field as it also counts
00052      - possible NULL-flag byte (see HA_KEY_NULL_LENGTH) [if null_bit != 0,
00053        the first byte stored at offset is 1 if null, 0 if non-null; the
00054        actual value is stored from offset+1].
00055      - possible HA_KEY_BLOB_LENGTH bytes needed to store actual value length.
00056   */
00057   uint16_t store_length;
00058   uint16_t key_type;
00059 private:
00060 public:
00061   uint16_t getKeyType() const
00062   {
00063     return key_type;
00064   }
00065   uint16_t fieldnr;     /* Fieldnum in UNIREG (1,2,3,...) */
00066   uint16_t key_part_flag;     /* 0 or HA_REVERSE_SORT */
00067   uint8_t type;
00068   uint8_t null_bit;     /* Position to null_bit */
00069 };
00070 
00071 
00072 class KeyInfo 
00073 {
00074 public:
00075   unsigned int  key_length;   /* Tot length of key */
00076   enum  ha_key_alg algorithm;
00077   unsigned long flags;      /* dupp key and pack flags */
00078   unsigned int key_parts;   /* How many key_parts */
00079   uint32_t  extra_length;
00080   unsigned int usable_key_parts;  /* Should normally be = key_parts */
00081   uint32_t  block_size;
00082   KeyPartInfo *key_part;
00083   char  *name;        /* Name of key */
00084   /*
00085     Array of AVG(#records with the same field value) for 1st ... Nth key part.
00086     0 means 'not known'.
00087     For temporary heap tables this member is NULL.
00088   */
00089   ulong *rec_per_key;
00090   Table *table;
00091   LEX_STRING comment;
00092 };
00093 
00094 
00095 class JoinTable;
00096 
00097 class RegInfo 
00098 {
00099 public:   /* Extra info about reg */
00100   JoinTable *join_tab;  /* Used by SELECT() */
00101   enum thr_lock_type lock_type;   /* How database is used */
00102   bool not_exists_optimize;
00103   bool impossible_range;
00104   RegInfo()
00105     : join_tab(NULL), lock_type(TL_UNLOCK),
00106       not_exists_optimize(false), impossible_range(false) {}
00107   void reset()
00108   {
00109     join_tab= NULL;
00110     lock_type= TL_UNLOCK;
00111     not_exists_optimize= false;
00112     impossible_range= false;
00113   }
00114 };
00115 
00116 class Session;
00117 class Cursor;
00118 namespace optimizer { class SqlSelect; }
00119 
00120 typedef int *(*update_var)(Session *, struct drizzle_show_var *);
00121 
00122 } /* namespace drizzled */
00123 
00124   /* Bits in form->status */
00125 #define STATUS_NO_RECORD  (1+2) /* Record isn't usably */
00126 #define STATUS_GARBAGE    1
00127 #define STATUS_NOT_FOUND  2 /* No record in database when needed */
00128 #define STATUS_NO_PARENT  4 /* Parent record wasn't found */
00129 #define STATUS_NULL_ROW   32  /* table->null_row is set */
00130