~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/function_engine/cursor.cc

  • Committer: Prafulla Tekawade
  • Date: 2010-08-06 11:21:12 UTC
  • mto: (1711.1.21 build) (1725.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1714.
  • Revision ID: prafulla_t@users.sourceforge.net-20100806112112-7w5u0s3nx9u67nzt
Fix for Bug 586051

1. test_if_ref method which checks whether predicate is already evaluated
   due to ref/eq_ref access or not was incorrectly removing a predicate 
   that was not implicitly evaluated due to ref access (due to presence of filesort ?)
   It was field=NULL predicate.
   Such predicate should be kept and execution engine will filter out rows
   correctly. Removal of such predicate led to returning of rows which had
   NULL for join/predicate columns.
2. field COMP_OP NULL will always false for all fields except when COMP_OP
   is NULL-safe equality operator. Modified range optimizer to return zero
   row count in such cases.
   Query now does not even run. It returns zero result. As such Fix(1) is not
   required but we might hit that case in some other query (I have not tried it
   yet)
3. Fixed Field::val_str to print "NULL" for literal NULL instead of "0". It
   added lot of confusion while debugging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
  tool= static_cast<Function *>(engine)->getFunction(name); 
49
49
//  assert(tool);
50
50
 
51
51
  record_id= 0;
67
67
int FunctionCursor::doStartTableScan(bool)
68
68
{
69
69
  rows_returned= 0;
70
 
  generator= tool->generator(getTable()->getFields());
 
70
  generator= tool->generator(table->getFields());
71
71
 
72
72
  return 0;
73
73
}
79
79
  ha_statistic_increment(&system_status_var::ha_read_rnd_next_count);
80
80
 
81
81
  /* Fix bug in the debug logic for field */
82
 
  for (Field **field= getTable()->getFields() ; *field ; field++)
 
82
  for (Field **field= table->getFields() ; *field ; field++)
83
83
  {
84
84
    (*field)->setWriteSet();
85
85
  }
86
86
 
87
 
  more_rows= generator->sub_populate(getTable()->getShare()->sizeFields());
 
87
  more_rows= generator->sub_populate(table->getShare()->sizeFields());
88
88
 
89
89
  if (more_rows)
90
90
  {
102
102
 
103
103
void FunctionCursor::position(const unsigned char *record)
104
104
{
105
 
  if (row_cache.size() <= record_id * getTable()->getShare()->getRecordLength())
 
105
  if (row_cache.size() <= record_id * table->getShare()->getRecordLength())
106
106
  {
107
 
    row_cache.resize(row_cache.size() + getTable()->getShare()->getRecordLength() * 100); // Hardwired at adding an additional 100 rows of storage
 
107
    row_cache.resize(row_cache.size() + table->getShare()->getRecordLength() * 100); // Hardwired at adding an additional 100 rows of storage
108
108
  }
109
 
  memcpy(&row_cache[record_id * getTable()->getShare()->getRecordLength()], record, getTable()->getShare()->getRecordLength());
 
109
  memcpy(&row_cache[record_id * table->getShare()->getRecordLength()], record, table->getShare()->getRecordLength());
110
110
  internal::my_store_ptr(ref, ref_length, record_id);
111
111
  record_id++;
112
112
}
151
151
  ha_statistic_increment(&system_status_var::ha_read_rnd_count);
152
152
  size_t position_id= (size_t)internal::my_get_ptr(pos, ref_length);
153
153
 
154
 
  assert(position_id * getTable()->getShare()->getRecordLength() < row_cache.size());
155
 
  memcpy(buf, &row_cache[position_id * getTable()->getShare()->getRecordLength()], getTable()->getShare()->getRecordLength());
 
154
  assert(position_id * table->getShare()->getRecordLength() < row_cache.size());
 
155
  memcpy(buf, &row_cache[position_id * table->getShare()->getRecordLength()], table->getShare()->getRecordLength());
156
156
 
157
157
  return 0;
158
158
}