~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/strfunc.cc

  • Committer: Stewart Smith
  • Date: 2011-02-24 07:46:16 UTC
  • mto: (2200.1.2 drizzle-staging)
  • mto: This revision was merged to the branch mainline in revision 2201.
  • Revision ID: stewart@flamingspork.com-20110224074616-l2rmp406vf78x71q
add ER_NO_LOCK_HELD error code, and expect it in case of UNLOCK TABLES without any locks held.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
/* Some useful string utility functions used by the MySQL server */
17
 
#include "config.h"
 
17
#include <config.h>
18
18
 
19
 
#include "drizzled/strfunc.h"
20
 
#include "drizzled/typelib.h"
21
 
#include "drizzled/charset_info.h"
22
 
#include "drizzled/global_charset_info.h"
 
19
#include <drizzled/typelib.h>
 
20
#include <drizzled/charset_info.h>
 
21
#include <drizzled/global_charset_info.h>
23
22
 
24
23
namespace drizzled
25
24
{
45
44
 
46
45
static const char field_separator=',';
47
46
 
48
 
uint64_t find_set(TYPELIB *lib, const char *str, uint32_t length,
 
47
uint64_t st_typelib::find_set(const char *str, uint32_t length,
49
48
                  const CHARSET_INFO * const cs,
50
 
                  char **err_pos, uint32_t *err_len, bool *set_warning)
 
49
                  char **err_pos, uint32_t *err_len, bool *set_warning) const
51
50
{
52
51
  const CHARSET_INFO * const strip= cs ? cs : &my_charset_utf8_general_ci;
53
52
  const char *end= str + strip->cset->lengthsp(strip, str, length);
65
64
      for (; pos != end && *pos != field_separator; pos++) 
66
65
      {}
67
66
      var_len= (uint32_t) (pos - start);
68
 
      uint32_t find= cs ? find_type2(lib, start, var_len, cs) :
69
 
                      find_type(lib, start, var_len, (bool) 0);
 
67
      uint32_t find= cs ? find_type2(start, var_len, cs) : find_type(start, var_len, false);
70
68
      if (!find)
71
69
      {
72
70
        *err_pos= (char*) start;
100
98
  > 0 position in TYPELIB->type_names +1
101
99
*/
102
100
 
103
 
uint32_t find_type(const TYPELIB *lib, const char *find, uint32_t length,
104
 
               bool part_match)
 
101
uint32_t st_typelib::find_type(const char *find, uint32_t length, bool part_match) const
105
102
{
106
103
  uint32_t found_count=0, found_pos=0;
107
104
  const char *end= find+length;
108
105
  const char *i;
109
106
  const char *j;
110
 
  for (uint32_t pos=0 ; (j=lib->type_names[pos++]) ; )
 
107
  for (uint32_t pos= 0 ; (j= type_names[pos++]) ; )
111
108
  {
112
109
    for (i=find ; i != end &&
113
110
           my_toupper(system_charset_info,*i) ==
141
138
    >0  Offset+1 in typelib for matched string
142
139
*/
143
140
 
144
 
uint32_t find_type2(const TYPELIB *typelib, const char *x, uint32_t length,
145
 
                const CHARSET_INFO * const cs)
 
141
uint32_t st_typelib::find_type2(const char *x, uint32_t length, const CHARSET_INFO *cs) const
146
142
{
147
 
  int pos;
 
143
  if (!count)
 
144
    return 0;
148
145
  const char *j;
149
 
 
150
 
  if (!typelib->count)
151
 
  {
152
 
    return(0);
153
 
  }
154
 
 
155
 
  for (pos=0 ; (j=typelib->type_names[pos]) ; pos++)
 
146
  for (int pos=0 ; (j= type_names[pos]) ; pos++)
156
147
  {
157
148
    if (!my_strnncoll(cs, (const unsigned char*) x, length,
158
 
                          (const unsigned char*) j, typelib->type_lengths[pos]))
159
 
      return(pos+1);
 
149
                          (const unsigned char*) j, type_lengths[pos]))
 
150
      return pos + 1;
160
151
  }
161
 
  return(0);
 
152
  return 0;
162
153
} /* find_type */
163
154
 
164
155
} /* namespace drizzled */