2
Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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.
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.
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
18
#ifndef NDB_DIST_PRIV_UTIL_H
19
#define NDB_DIST_PRIV_UTIL_H
21
class Ndb_dist_priv_util {
22
size_t m_iter_curr_table;
29
const char* database() const { return "mysql"; }
31
// Iterator for distributed priv tables name
32
const char* iter_next_table()
34
static const char* tables[] =
35
{ "user", "db", "tables_priv", "columns_priv", "procs_priv", "host",
38
if (m_iter_curr_table >= (sizeof(tables) / sizeof(tables[0])))
41
return tables[m_iter_curr_table-1];
44
// Reset iterator to start at first table name
45
void iter_reset() { m_iter_curr_table = 0; }
47
// Determine if a given table name is in the list
48
// of distributed priv tables
51
is_distributed_priv_table(const char *db, const char *table)
53
Ndb_dist_priv_util dist_priv;
54
if (strcmp(db, dist_priv.database()))
56
return false; // Ignore tables not in dist_priv database
58
const char* priv_table_name;
59
while((priv_table_name= dist_priv.iter_next_table()))
61
if (strcmp(table, priv_table_name) == 0)