Drizzled Public API Documentation

hp_extra.cc

00001 /* Copyright (C) 2000-2001, 2004 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 /* Extra functions we want to do with a database */
00017 /* - Set flags for quicker databasehandler */
00018 /* - Set databasehandler to normal */
00019 /* - Reset recordpointers as after open database */
00020 
00021 #include "heap_priv.h"
00022 
00023 using namespace drizzled;
00024 
00025 static void heap_extra_keyflag(register HP_INFO *info,
00026                                enum ha_extra_function function);
00027 
00028 
00029   /* set extra flags for database */
00030 
00031 int heap_extra(register HP_INFO *info, enum ha_extra_function function)
00032 {
00033   switch (function) {
00034   case HA_EXTRA_RESET_STATE:
00035     heap_reset(info);
00036   case HA_EXTRA_NO_READCHECK:
00037     info->opt_flag&= ~READ_CHECK_USED;  /* No readcheck */
00038     break;
00039   case HA_EXTRA_READCHECK:
00040     info->opt_flag|= READ_CHECK_USED;
00041     break;
00042   case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
00043   case HA_EXTRA_CHANGE_KEY_TO_DUP:
00044     heap_extra_keyflag(info, function);
00045     break;
00046   default:
00047     break;
00048   }
00049   return(0);
00050 } /* heap_extra */
00051 
00052 
00053 int heap_reset(HP_INFO *info)
00054 {
00055   info->lastinx= -1;
00056   info->current_record= UINT32_MAX;
00057   info->current_hash_ptr=0;
00058   info->update=0;
00059   info->next_block=0;
00060   return 0;
00061 }
00062 
00063 
00064 /*
00065     Start/Stop Inserting Duplicates Into a Table, WL#1648.
00066  */
00067 static void heap_extra_keyflag(register HP_INFO *info,
00068                                enum ha_extra_function function)
00069 {
00070   for (uint32_t idx= 0; idx< info->getShare()->keys; idx++)
00071   {
00072     switch (function) {
00073     case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
00074       info->getShare()->keydef[idx].flag|= HA_NOSAME;
00075       break;
00076     case HA_EXTRA_CHANGE_KEY_TO_DUP:
00077       info->getShare()->keydef[idx].flag&= ~(HA_NOSAME);
00078       break;
00079     default:
00080       break;
00081     }
00082   }
00083 }