~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/function_engine/cursor.cc

  • Committer: Monty Taylor
  • Date: 2010-06-15 16:57:34 UTC
  • Revision ID: mordred@inaugust.com-20100615165734-qwi2zijn86510fiw
Added include.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2009 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
 
21
#include "config.h"
22
22
 
23
23
#include <plugin/function_engine/cursor.h>
24
24
#include <drizzled/session.h>
25
 
#include <drizzled/internal/my_sys.h>
 
25
#include "drizzled/internal/my_sys.h"
26
26
 
27
27
#include <unistd.h>
28
28
#include <fcntl.h>
37
37
*****************************************************************************/
38
38
 
39
39
FunctionCursor::FunctionCursor(plugin::StorageEngine &engine_arg,
40
 
                               Table &table_arg) :
 
40
                               TableShare &table_arg) :
41
41
  Cursor(engine_arg, table_arg),
42
42
  estimate_of_rows(100), // Completely fabricated, I used to use the value 2.
43
43
  rows_returned(0)
45
45
 
46
46
int FunctionCursor::open(const char *name, int, uint32_t)
47
47
{
48
 
  tool= static_cast<Function *>(getEngine())->getFunction(name); 
 
48
  string tab_name(name);
 
49
  transform(tab_name.begin(), tab_name.end(),
 
50
            tab_name.begin(), ::tolower);
 
51
  tool= static_cast<Function *>(engine)->getFunction(tab_name); 
49
52
//  assert(tool);
50
53
 
51
54
  record_id= 0;
67
70
int FunctionCursor::doStartTableScan(bool)
68
71
{
69
72
  rows_returned= 0;
70
 
  generator= tool->generator(getTable()->getFields());
 
73
  generator= tool->generator(table->getFields());
71
74
 
72
75
  return 0;
73
76
}
79
82
  ha_statistic_increment(&system_status_var::ha_read_rnd_next_count);
80
83
 
81
84
  /* Fix bug in the debug logic for field */
82
 
  for (Field **field= getTable()->getFields() ; *field ; field++)
 
85
  for (Field **field= table->getFields() ; *field ; field++)
83
86
  {
84
87
    (*field)->setWriteSet();
85
88
  }
86
89
 
87
 
  more_rows= generator->sub_populate(getTable()->getShare()->sizeFields());
 
90
  more_rows= generator->sub_populate(table->getShare()->sizeFields());
88
91
 
89
92
  if (more_rows)
90
93
  {
102
105
 
103
106
void FunctionCursor::position(const unsigned char *record)
104
107
{
105
 
  if (row_cache.size() <= record_id * getTable()->getShare()->getRecordLength())
 
108
  if (row_cache.size() <= record_id * table->getShare()->getRecordLength())
106
109
  {
107
 
    row_cache.resize(row_cache.size() + getTable()->getShare()->getRecordLength() * 100); // Hardwired at adding an additional 100 rows of storage
 
110
    row_cache.resize(row_cache.size() + table->getShare()->getRecordLength() * 100); // Hardwired at adding an additional 100 rows of storage
108
111
  }
109
 
  memcpy(&row_cache[record_id * getTable()->getShare()->getRecordLength()], record, getTable()->getShare()->getRecordLength());
 
112
  memcpy(&row_cache[record_id * table->getShare()->getRecordLength()], record, table->getShare()->getRecordLength());
110
113
  internal::my_store_ptr(ref, ref_length, record_id);
111
114
  record_id++;
112
115
}
151
154
  ha_statistic_increment(&system_status_var::ha_read_rnd_count);
152
155
  size_t position_id= (size_t)internal::my_get_ptr(pos, ref_length);
153
156
 
154
 
  assert(position_id * getTable()->getShare()->getRecordLength() < row_cache.size());
155
 
  memcpy(buf, &row_cache[position_id * getTable()->getShare()->getRecordLength()], getTable()->getShare()->getRecordLength());
 
157
  assert(position_id * table->getShare()->getRecordLength() < row_cache.size());
 
158
  memcpy(buf, &row_cache[position_id * table->getShare()->getRecordLength()], table->getShare()->getRecordLength());
156
159
 
157
160
  return 0;
158
161
}