~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty
  • Date: 2008-11-07 05:51:15 UTC
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: mordred@palanthas.inaugust.com-20081107055115-0275gvq62buzls77
Fixed a decimal sign thing.

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) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 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
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/insert.h>
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/functions/str/insert.h>
23
23
#include <drizzled/error.h>
24
 
#include <drizzled/session.h>
25
 
 
26
 
namespace drizzled
27
 
{
28
24
 
29
25
String *Item_func_insert::val_str(String *str)
30
26
{
40
36
 
41
37
  if (args[0]->null_value || args[1]->null_value || args[2]->null_value ||
42
38
      args[3]->null_value)
43
 
    goto null;
 
39
    goto null; /* purecov: inspected */
44
40
 
45
 
  if ((start < 0) || (start > static_cast<int64_t>(res->length())))
 
41
  if ((start < 0) || (start > res->length()))
46
42
    return res;                                 // Wrong param; skip insert
47
 
  if ((length < 0) || (length > static_cast<int64_t>(res->length())))
 
43
  if ((length < 0) || (length > res->length()))
48
44
    length= res->length();
49
45
 
50
46
  /* start and length are now sufficiently valid to pass to charpos function */
52
48
   length= res->charpos((int) length, (uint32_t) start);
53
49
 
54
50
  /* Re-testing with corrected params */
55
 
  if (start > static_cast<int64_t>(res->length()))
56
 
    return res;
57
 
  if (length > static_cast<int64_t>(res->length()) - start)
 
51
  if (start > res->length())
 
52
    return res; /* purecov: inspected */        // Wrong param; skip insert
 
53
  if (length > res->length() - start)
58
54
    length= res->length() - start;
59
55
 
60
56
  if ((uint64_t) (res->length() - length + res2->length()) >
61
 
      (uint64_t) session.variables.max_allowed_packet)
 
57
      (uint64_t) current_session->variables.max_allowed_packet)
62
58
  {
63
 
    push_warning_printf(&session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
59
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
64
60
                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
65
61
                        ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
66
 
                        func_name(), session.variables.max_allowed_packet);
 
62
                        func_name(), current_session->variables.max_allowed_packet);
67
63
    goto null;
68
64
  }
69
65
  res=copy_if_not_alloced(str,res,res->length());
91
87
  }
92
88
  max_length= (ulong) max_result_length;
93
89
}
94
 
 
95
 
} /* namespace drizzled */