~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/functions/str/pad.cc

  • Committer: Monty Taylor
  • Date: 2008-11-16 20:15:33 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116201533-d0f19s1bk1h95iyw
Removed a big bank of includes from item.h.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
22
 
#include <drizzled/function/str/pad.h>
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/functions/str/pad.h>
23
23
#include <drizzled/error.h>
24
 
#include <drizzled/function/str/alloc_buffer.h>
25
 
#include <drizzled/session.h>
26
 
 
27
 
namespace drizzled
28
 
{
 
24
#include <drizzled/functions/str/alloc_buffer.h>
29
25
 
30
26
void Item_func_rpad::fix_length_and_dec()
31
27
{
75
71
  String *res= args[0]->val_str(str);
76
72
  String *rpad= args[2]->val_str(&rpad_str);
77
73
 
78
 
  if (!res || args[1]->null_value || !rpad ||
 
74
  if (!res || args[1]->null_value || !rpad || 
79
75
      ((count < 0) && !args[1]->unsigned_flag))
80
76
    goto err;
81
77
  null_value=0;
134
130
  // Handle character set for args[0] and args[2].
135
131
  if (agg_arg_charsets(collation, &args[0], 2, MY_COLL_ALLOW_CONV, 2))
136
132
    return;
137
 
 
 
133
  
138
134
  if (args[1]->const_item())
139
135
  {
140
136
    uint64_t length= 0;
176
172
  String *res= args[0]->val_str(&tmp_value);
177
173
  String *pad= args[2]->val_str(&lpad_str);
178
174
 
179
 
  if (!res || args[1]->null_value || !pad ||
 
175
  if (!res || args[1]->null_value || !pad ||  
180
176
      ((count < 0) && !args[1]->unsigned_flag))
181
 
    goto err;
 
177
    goto err;  
182
178
  null_value=0;
183
179
  /* Assumes that the maximum length of a String is < INT32_MAX. */
184
180
  /* Set here so that rest of code sees out-of-bound value as such. */
192
188
    res->length(res->charpos((int) count));
193
189
    return res;
194
190
  }
195
 
 
 
191
  
196
192
  pad_char_length= pad->numchars();
197
193
  byte_count= count * collation.collation->mbmaxlen;
198
 
 
 
194
  
199
195
  if ((uint64_t) byte_count > current_session->variables.max_allowed_packet)
200
196
  {
201
197
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
208
204
  if (args[2]->null_value || !pad_char_length ||
209
205
      str->alloc((uint32_t) byte_count))
210
206
    goto err;
211
 
 
 
207
  
212
208
  str->length(0);
213
209
  str->set_charset(collation.collation);
214
210
  count-= res_char_length;
229
225
  return 0;
230
226
}
231
227
 
232
 
} /* namespace drizzled */