~jaypipes/drizzle/split-xa-resource-manager

« back to all changes in this revision

Viewing changes to plugin/schema_dictionary/index_parts.cc

  • Committer: Jay Pipes
  • Date: 2010-02-14 20:26:43 UTC
  • mfrom: (1273.1.27 staging)
  • Revision ID: jpipes@serialcoder-20100214202643-ahuqvc8rhn8u7y33
Merge trunk and resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2010 Sun Microsystems
 
5
 *
 
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; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#include "config.h"
 
22
#include "plugin/schema_dictionary/dictionary.h"
 
23
 
 
24
using namespace std;
 
25
using namespace drizzled;
 
26
 
 
27
IndexPartsTool::IndexPartsTool() :
 
28
  IndexesTool("INDEX_PARTS")
 
29
{
 
30
  add_field("TABLE_SCHEMA");
 
31
  add_field("TABLE_NAME");
 
32
  add_field("INDEX_NAME");
 
33
  add_field("COLUMN_NAME");
 
34
  add_field("COLUMN_NUMBER", plugin::TableFunction::NUMBER);
 
35
  add_field("COMPARE_LENGTH", plugin::TableFunction::NUMBER);
 
36
  add_field("IS_ORDER_REVERSE", plugin::TableFunction::BOOLEAN);
 
37
}
 
38
 
 
39
IndexPartsTool::Generator::Generator(Field **arg) :
 
40
  IndexesTool::Generator(arg),
 
41
  index_part_iterator(0),
 
42
  is_index_part_primed(false)
 
43
{
 
44
}
 
45
 
 
46
 
 
47
bool IndexPartsTool::Generator::nextIndexPartsCore()
 
48
{
 
49
  if (is_index_part_primed)
 
50
  {
 
51
    index_part_iterator++;
 
52
  }
 
53
  else
 
54
  {
 
55
    if (not isIndexesPrimed())
 
56
      return false;
 
57
 
 
58
    index_part_iterator= 0;
 
59
    is_index_part_primed= true;
 
60
  }
 
61
 
 
62
  if (index_part_iterator >= getIndex().index_part_size())
 
63
    return false;
 
64
 
 
65
  index_part= getIndex().index_part(index_part_iterator);
 
66
 
 
67
  return true;
 
68
}
 
69
 
 
70
bool IndexPartsTool::Generator::nextIndexParts()
 
71
{
 
72
  while (not nextIndexPartsCore())
 
73
  {
 
74
    if (not nextIndex())
 
75
      return false;
 
76
    is_index_part_primed= false;
 
77
  }
 
78
 
 
79
  return true;
 
80
}
 
81
 
 
82
bool IndexPartsTool::Generator::populate()
 
83
{
 
84
  if (not nextIndexParts())
 
85
    return false;
 
86
 
 
87
  fill();
 
88
 
 
89
  return true;
 
90
}
 
91
 
 
92
void IndexPartsTool::Generator::fill()
 
93
{
 
94
  /* TABLE_SCHEMA */
 
95
  push(schema_name());
 
96
 
 
97
  /* TABLE_NAME */
 
98
  push(table_name());
 
99
 
 
100
  /* INDEX_NAME */
 
101
  push(getIndex().name());
 
102
 
 
103
  /* COLUMN_NAME */
 
104
  push(getTableProto().field(index_part.fieldnr()).name());
 
105
 
 
106
  /* COLUMN_NUMBER */
 
107
  push(index_part.fieldnr());
 
108
 
 
109
  /* COMPARE_LENGTH */
 
110
  push(index_part.compare_length());
 
111
 
 
112
  /* IS_ORDER_REVERSE */
 
113
  push(index_part.in_reverse_order());
 
114
}