1 /* Copyright (c) 2000-2003, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc.
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, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24 /*
25 Extra functions we want to do with a database
26 - All flags, exept record-cache-flags, are set in all used databases
27 record-cache-flags are set in myrg_rrnd when we are changing database.
28 */
29
30 #include "myrg_def.h"
31
myrg_extra(MYRG_INFO * info,enum ha_extra_function function,void * extra_arg)32 int myrg_extra(MYRG_INFO *info,enum ha_extra_function function,
33 void *extra_arg)
34 {
35 int error,save_error=0;
36 MYRG_TABLE *file;
37 DBUG_ENTER("myrg_extra");
38 DBUG_PRINT("info",("function: %lu", (ulong) function));
39
40 if (!info->children_attached)
41 DBUG_RETURN(1);
42 if (function == HA_EXTRA_CACHE)
43 {
44 info->cache_in_use=1;
45 info->cache_size= (extra_arg ? *(ulong*) extra_arg :
46 my_default_record_cache_size);
47 }
48 else
49 {
50 if (function == HA_EXTRA_NO_CACHE ||
51 function == HA_EXTRA_PREPARE_FOR_UPDATE)
52 info->cache_in_use=0;
53 if (function == HA_EXTRA_RESET_STATE)
54 {
55 info->current_table=0;
56 info->last_used_table=info->open_tables;
57 }
58 for (file=info->open_tables ; file != info->end_table ; file++)
59 {
60 if ((error=mi_extra(file->table, function, extra_arg)))
61 save_error=error;
62 }
63 }
64 DBUG_RETURN(save_error);
65 }
66
67
myrg_extrafunc(MYRG_INFO * info,invalidator_by_filename inv)68 void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv)
69 {
70 MYRG_TABLE *file;
71 DBUG_ENTER("myrg_extrafunc");
72
73 for (file=info->open_tables ; file != info->end_table ; file++)
74 file->table->s->invalidator = inv;
75
76 DBUG_VOID_RETURN;
77 }
78
79
myrg_reset(MYRG_INFO * info)80 int myrg_reset(MYRG_INFO *info)
81 {
82 int save_error= 0;
83 MYRG_TABLE *file;
84 DBUG_ENTER("myrg_reset");
85
86 info->cache_in_use=0;
87 info->current_table=0;
88 info->last_used_table= info->open_tables;
89
90 /*
91 This is normally called with detached children.
92 Return OK as this is the normal case.
93 */
94 if (!info->children_attached)
95 DBUG_RETURN(0);
96
97 for (file=info->open_tables ; file != info->end_table ; file++)
98 {
99 int error;
100 if ((error= mi_reset(file->table)))
101 save_error=error;
102 }
103 DBUG_RETURN(save_error);
104 }
105