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