drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
hp_extra.cc
1/* Copyright (C) 2000-2001, 2004 MySQL AB
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16/* Extra functions we want to do with a database */
17/* - Set flags for quicker databasehandler */
18/* - Set databasehandler to normal */
19/* - Reset recordpointers as after open database */
20
21#include "heap_priv.h"
22
23using namespace drizzled;
24
25static void heap_extra_keyflag(HP_INFO *info,
26 enum ha_extra_function function);
27
28
29 /* set extra flags for database */
30
31int heap_extra(HP_INFO *info, enum ha_extra_function function)
32{
33 switch (function) {
34 case HA_EXTRA_RESET_STATE:
35 heap_reset(info);
36 /* fallthrough */
37 case HA_EXTRA_NO_READCHECK:
38 info->opt_flag&= ~READ_CHECK_USED; /* No readcheck */
39 break;
40 case HA_EXTRA_READCHECK:
41 info->opt_flag|= READ_CHECK_USED;
42 break;
43 case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
44 case HA_EXTRA_CHANGE_KEY_TO_DUP:
45 heap_extra_keyflag(info, function);
46 break;
47 default:
48 break;
49 }
50 return(0);
51} /* heap_extra */
52
53
54int heap_reset(HP_INFO *info)
55{
56 info->lastinx= -1;
57 info->current_record= UINT32_MAX;
58 info->current_hash_ptr=0;
59 info->update=0;
60 info->next_block=0;
61 return 0;
62}
63
64
65/*
66 Start/Stop Inserting Duplicates Into a Table, WL#1648.
67 */
68static void heap_extra_keyflag(HP_INFO *info,
69 enum ha_extra_function function)
70{
71 for (uint32_t idx= 0; idx< info->getShare()->keys; idx++)
72 {
73 switch (function) {
74 case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
75 info->getShare()->keydef[idx].flag|= HA_NOSAME;
76 break;
77 case HA_EXTRA_CHANGE_KEY_TO_DUP:
78 info->getShare()->keydef[idx].flag&= ~(HA_NOSAME);
79 break;
80 default:
81 break;
82 }
83 }
84}
TODO: Rename this file - func.h is stupid.