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 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 St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17/*
18 Extra functions we want to do with a database
19 - All flags, exept record-cache-flags, are set in all used databases
20 record-cache-flags are set in myrg_rrnd when we are changing database.
21*/
22
23#include "myrg_def.h"
24
25int myrg_extra(MYRG_INFO *info,enum ha_extra_function function,
26 void *extra_arg)
27{
28 int error,save_error=0;
29 MYRG_TABLE *file;
30 DBUG_ENTER("myrg_extra");
31 DBUG_PRINT("info",("function: %lu", (ulong) function));
32
33 if (!info->children_attached)
34 DBUG_RETURN(1);
35 if (function == HA_EXTRA_CACHE)
36 {
37 info->cache_in_use=1;
38 info->cache_size= (extra_arg ? *(ulong*) extra_arg :
39 my_default_record_cache_size);
40 }
41 else
42 {
43 if (function == HA_EXTRA_NO_CACHE ||
44 function == HA_EXTRA_PREPARE_FOR_UPDATE)
45 info->cache_in_use=0;
46 if (function == HA_EXTRA_RESET_STATE)
47 {
48 info->current_table=0;
49 info->last_used_table=info->open_tables;
50 }
51 for (file=info->open_tables ; file != info->end_table ; file++)
52 {
53 if ((error=mi_extra(file->table, function, extra_arg)))
54 save_error=error;
55 }
56 }
57 DBUG_RETURN(save_error);
58}
59
60
61void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv)
62{
63 MYRG_TABLE *file;
64 DBUG_ENTER("myrg_extrafunc");
65
66 for (file=info->open_tables ; file != info->end_table ; file++)
67 file->table->s->invalidator = inv;
68
69 DBUG_VOID_RETURN;
70}
71
72
73int myrg_reset(MYRG_INFO *info)
74{
75 int save_error= 0;
76 MYRG_TABLE *file;
77 DBUG_ENTER("myrg_reset");
78
79 info->cache_in_use=0;
80 info->current_table=0;
81 info->last_used_table= info->open_tables;
82
83 /*
84 This is normally called with detached children.
85 Return OK as this is the normal case.
86 */
87 if (!info->children_attached)
88 DBUG_RETURN(0);
89
90 for (file=info->open_tables ; file != info->end_table ; file++)
91 {
92 int error;
93 if ((error= mi_reset(file->table)))
94 save_error=error;
95 }
96 DBUG_RETURN(save_error);
97}
98