~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/min_max.cc

  • Committer: Brian Aker
  • Date: 2010-12-15 21:28:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1998.
  • Revision ID: brian@tangent.org-20101215212847-c52kuprsbrcm8sfk
Update name usage for user defined objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
  }
142
142
  switch (cmp_type) {
143
143
  case INT_RESULT:
144
 
    {
145
 
      int64_t nr=val_int();
146
 
      if (null_value)
147
 
        return 0;
148
 
      str->set_int(nr, unsigned_flag, &my_charset_bin);
149
 
      return str;
150
 
    }
151
 
 
 
144
  {
 
145
    int64_t nr=val_int();
 
146
    if (null_value)
 
147
      return 0;
 
148
    str->set_int(nr, unsigned_flag, &my_charset_bin);
 
149
    return str;
 
150
  }
152
151
  case DECIMAL_RESULT:
153
 
    {
154
 
      my_decimal dec_buf, *dec_val= val_decimal(&dec_buf);
155
 
      if (null_value)
156
 
        return 0;
157
 
      my_decimal2string(E_DEC_FATAL_ERROR, dec_val, 0, 0, 0, str);
158
 
      return str;
159
 
    }
160
 
 
 
152
  {
 
153
    my_decimal dec_buf, *dec_val= val_decimal(&dec_buf);
 
154
    if (null_value)
 
155
      return 0;
 
156
    my_decimal2string(E_DEC_FATAL_ERROR, dec_val, 0, 0, 0, str);
 
157
    return str;
 
158
  }
161
159
  case REAL_RESULT:
162
 
    {
163
 
      double nr= val_real();
164
 
      if (null_value)
165
 
        return 0;
166
 
      str->set_real(nr,decimals,&my_charset_bin);
167
 
      return str;
168
 
    }
169
 
 
 
160
  {
 
161
    double nr= val_real();
 
162
    if (null_value)
 
163
      return 0;
 
164
    str->set_real(nr,decimals,&my_charset_bin);
 
165
    return str;
 
166
  }
170
167
  case STRING_RESULT:
 
168
  {
 
169
    String *res= NULL;
 
170
 
 
171
    for (uint32_t i=0; i < arg_count ; i++)
171
172
    {
172
 
      String *res= NULL;
173
 
 
174
 
      for (uint32_t i=0; i < arg_count ; i++)
 
173
      if (i == 0)
 
174
        res=args[i]->val_str(str);
 
175
      else
175
176
      {
176
 
        if (i == 0)
177
 
          res=args[i]->val_str(str);
178
 
        else
179
 
        {
180
 
          String *res2;
181
 
          res2= args[i]->val_str(res == str ? &tmp_value : str);
182
 
          if (res2)
183
 
          {
184
 
            int cmp= sortcmp(res,res2,collation.collation);
185
 
            if ((cmp_sign < 0 ? cmp : -cmp) < 0)
186
 
              res=res2;
187
 
          }
188
 
        }
189
 
        if ((null_value= args[i]->null_value))
190
 
          return 0;
 
177
        String *res2;
 
178
        res2= args[i]->val_str(res == str ? &tmp_value : str);
 
179
        if (res2)
 
180
        {
 
181
          int cmp= sortcmp(res,res2,collation.collation);
 
182
          if ((cmp_sign < 0 ? cmp : -cmp) < 0)
 
183
            res=res2;
 
184
        }
191
185
      }
192
 
      res->set_charset(collation.collation);
193
 
      return res;
 
186
      if ((null_value= args[i]->null_value))
 
187
        return 0;
194
188
    }
195
 
 
 
189
    res->set_charset(collation.collation);
 
190
    return res;
 
191
  }
196
192
  case ROW_RESULT:
 
193
  default:
197
194
    // This case should never be chosen
198
195
    assert(0);
199
196
    return 0;
200
197
  }
201
 
 
202
198
  return 0;                                     // Keep compiler happy
203
199
}
204
200