~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/varstring.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:
56
56
                                 unsigned char *null_ptr_arg,
57
57
                                 unsigned char null_bit_arg,
58
58
                                 const char *field_name_arg,
59
 
                                 const CHARSET_INFO * const cs) :
60
 
  Field_str(ptr_arg,
61
 
            len_arg,
62
 
            null_ptr_arg,
63
 
            null_bit_arg,
64
 
            field_name_arg, cs),
65
 
length_bytes(length_bytes_arg)
 
59
                                 TableShare *share,
 
60
                                 const CHARSET_INFO * const cs)
 
61
  :Field_str(ptr_arg,
 
62
             len_arg,
 
63
             null_ptr_arg,
 
64
             null_bit_arg,
 
65
             field_name_arg, cs),
 
66
   length_bytes(length_bytes_arg)
66
67
{
 
68
  share->varchar_fields++;
67
69
}
68
70
 
69
71
Field_varstring::Field_varstring(uint32_t len_arg,
70
72
                                 bool maybe_null_arg,
71
73
                                 const char *field_name_arg,
72
 
                                 const CHARSET_INFO * const cs) :
73
 
  Field_str((unsigned char*) 0,
74
 
            len_arg,
75
 
            maybe_null_arg ? (unsigned char*) "": 0,
76
 
            0,
77
 
            field_name_arg,
78
 
            cs),
79
 
  length_bytes(len_arg < 256 ? 1 :2)
 
74
                                 TableShare *share,
 
75
                                 const CHARSET_INFO * const cs)
 
76
  :Field_str((unsigned char*) 0,
 
77
             len_arg,
 
78
             maybe_null_arg ? (unsigned char*) "": 0,
 
79
             0,
 
80
             field_name_arg,
 
81
             cs),
 
82
   length_bytes(len_arg < 256 ? 1 :2)
80
83
{
 
84
  share->varchar_fields++;
81
85
}
82
86
 
83
87
int Field_varstring::store(const char *from,uint32_t length, const CHARSET_INFO * const cs)
116
120
  char buff[64];
117
121
  uint32_t  length;
118
122
  length= (uint32_t) (field_charset->cset->int64_t10_to_str)(field_charset,
119
 
                                                             buff,
120
 
                                                             sizeof(buff),
121
 
                                                             (unsigned_val ? 10: -10),
122
 
                                                             nr);
 
123
                                                          buff,
 
124
                                                          sizeof(buff),
 
125
                                                          (unsigned_val ? 10:
 
126
                                                           -10),
 
127
                                                           nr);
123
128
  return Field_varstring::store(buff, length, field_charset);
124
129
}
125
130
 
219
224
  uint32_t local_char_length= max_key_length / field_charset->mbmaxlen;
220
225
 
221
226
  local_char_length= my_charpos(field_charset, ptr + length_bytes,
222
 
                                ptr + length_bytes + length, local_char_length);
 
227
                          ptr + length_bytes + length, local_char_length);
223
228
  set_if_smaller(length, local_char_length);
224
229
  return field_charset->coll->strnncollsp(field_charset,
225
230
                                          ptr + length_bytes,
264
269
  }
265
270
 
266
271
  tot_length= my_strnxfrm(field_charset,
267
 
                          to, length, ptr + length_bytes,
268
 
                          tot_length);
 
272
                          to, length, ptr + length_bytes,
 
273
                          tot_length);
269
274
  assert(tot_length == length);
270
275
}
271
276