1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_RPL_TBLMAP_H
21
#define DRIZZLED_RPL_TBLMAP_H
23
/* Forward declarations */
30
The table mapping is used to map table id's to table pointers
33
RELAY_LOG For mapping table id:s to tables when receiving events.
38
in the table_mapping class, the memory is allocated and never freed (until
39
destruction). So this is a good candidate for allocating inside a MEM_ROOT:
40
it gives the efficient allocation in chunks (like in expand()). So I have
41
introduced a MEM_ROOT.
43
Note that inheriting from Sql_alloc had no effect: it has effects only when
44
"ptr= new table_mapping" is called, and this is never called. And it would
45
then allocate from session->mem_root which is a highly volatile object (reset
46
from example after executing each query, see dispatch_command(), it has a
47
free_root() at end); as the table_mapping object is supposed to live longer
48
than a query, it was dangerous.
49
A dedicated MEM_ROOT needs to be used, see below.
68
Table* get_table(ulong table_id);
70
int set_table(ulong table_id, Table* table);
71
int remove_table(ulong table_id);
73
ulong count() const { return m_table_ids.records; }
77
This is a POD (Plain Old Data). Keep it that way (we apply offsetof() to
78
it, which only works for PODs)
88
entry *find_entry(ulong table_id)
90
return (entry *)hash_search(&m_table_ids,
91
(unsigned char*)&table_id,
97
Head of the list of free entries; "free" in the sense that it's an
98
allocated entry free for use, NOT in the sense that it's freed
103
/* Correspondance between an id (a number) and a Table object */
107
#endif /* DRIZZLED_RPL_TBLMAP_H */