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 #pragma once 00022 00023 #include <drizzled/base.h> 00024 #include <drizzled/definitions.h> 00025 #include <drizzled/lex_string.h> 00026 #include <drizzled/thr_lock.h> 00027 00028 namespace drizzled { 00029 00030 class KeyPartInfo 00031 { /* Info about a key part */ 00032 public: 00033 Field *field; 00034 unsigned int offset; /* offset in record (from 0) */ 00035 unsigned int null_offset; /* Offset to null_bit in record */ 00036 /* Length of key part in bytes, excluding NULL flag and length bytes */ 00037 uint16_t length; 00038 /* 00039 Number of bytes required to store the keypart value. This may be 00040 different from the "length" field as it also counts 00041 - possible NULL-flag byte (see HA_KEY_NULL_LENGTH) [if null_bit != 0, 00042 the first byte stored at offset is 1 if null, 0 if non-null; the 00043 actual value is stored from offset+1]. 00044 - possible HA_KEY_BLOB_LENGTH bytes needed to store actual value length. 00045 */ 00046 uint16_t store_length; 00047 uint16_t key_type; 00048 private: 00049 public: 00050 uint16_t getKeyType() const 00051 { 00052 return key_type; 00053 } 00054 uint16_t fieldnr; /* Fieldnum in UNIREG (1,2,3,...) */ 00055 uint16_t key_part_flag; /* 0 or HA_REVERSE_SORT */ 00056 uint8_t type; 00057 uint8_t null_bit; /* Position to null_bit */ 00058 }; 00059 00060 00061 class KeyInfo 00062 { 00063 public: 00064 unsigned int key_length; /* Tot length of key */ 00065 enum ha_key_alg algorithm; 00066 unsigned long flags; /* dupp key and pack flags */ 00067 unsigned int key_parts; /* How many key_parts */ 00068 uint32_t extra_length; 00069 unsigned int usable_key_parts; /* Should normally be = key_parts */ 00070 uint32_t block_size; 00071 KeyPartInfo *key_part; 00072 const char* name; /* Name of key */ 00073 /* 00074 Array of AVG(#records with the same field value) for 1st ... Nth key part. 00075 0 means 'not known'. 00076 For temporary heap tables this member is NULL. 00077 */ 00078 ulong *rec_per_key; 00079 Table *table; 00080 str_ref comment; 00081 }; 00082 00083 00084 class RegInfo 00085 { 00086 public: /* Extra info about reg */ 00087 JoinTable *join_tab; /* Used by SELECT() */ 00088 enum thr_lock_type lock_type; /* How database is used */ 00089 bool not_exists_optimize; 00090 bool impossible_range; 00091 RegInfo() 00092 : join_tab(NULL), lock_type(TL_UNLOCK), 00093 not_exists_optimize(false), impossible_range(false) {} 00094 void reset() 00095 { 00096 join_tab= NULL; 00097 lock_type= TL_UNLOCK; 00098 not_exists_optimize= false; 00099 impossible_range= false; 00100 } 00101 }; 00102 00103 typedef int *(*update_var)(Session *, struct drizzle_show_var *); 00104 00105 } /* namespace drizzled */ 00106 00107 /* Bits in form->status */ 00108 #define STATUS_NO_RECORD (1+2) /* Record isn't usably */ 00109 #define STATUS_GARBAGE 1 00110 #define STATUS_NOT_FOUND 2 /* No record in database when needed */ 00111 #define STATUS_NO_PARENT 4 /* Parent record wasn't found */ 00112 #define STATUS_NULL_ROW 32 /* table->null_row is set */ 00113