20
20
#include <drizzled/charset_info.h>
21
21
#include <drizzled/global_charset_info.h>
27
Return bitmap for strings used in a set
32
str Strings of set-strings separated by ','
33
err_pos If error, set to point to start of wrong set string
34
err_len If error, set to the length of wrong set string
35
set_warning Set to 1 if some string in set couldn't be used
38
We delete all end space from str before comparison
41
bitmap of all sets found in x.
42
set_warning is set to 1 if there was any sets that couldn't be set
45
static const char field_separator=',';
47
uint64_t TYPELIB::find_set(const char *str, uint32_t length,
48
const charset_info_st * const cs,
49
char **err_pos, uint32_t *err_len, bool *set_warning) const
51
const charset_info_st * const strip= cs ? cs : &my_charset_utf8_general_ci;
52
const char *end= str + strip->cset->lengthsp(strip, str, length);
54
*err_pos= 0; // No error yet
57
const char *start= str;
60
const char *pos= start;
64
for (; pos != end && *pos != field_separator; pos++)
66
var_len= (uint32_t) (pos - start);
67
uint32_t find= cs ? find_type2(start, var_len, cs) : find_type(start, var_len, false);
70
*err_pos= (char*) start;
75
found|= ((int64_t) 1 << (find - 1));
86
26
Function to find a string in a TYPELIB
101
41
uint32_t TYPELIB::find_type(const char *find, uint32_t length, bool part_match) const
103
43
uint32_t found_count=0, found_pos=0;
104
const char *end= find+length;
44
const char* end= find + length;
107
47
for (uint32_t pos= 0 ; (j= type_names[pos++]) ; )
109
for (i=find ; i != end &&
110
my_toupper(system_charset_info,*i) ==
111
my_toupper(system_charset_info,*j) ; i++, j++) ;
49
for (i= find ; i != end && my_toupper(system_charset_info, *i) == my_toupper(system_charset_info, *j); i++, j++)
120
return(found_count == 1 && part_match ? found_pos : 0);
60
return found_count == 1 && part_match ? found_pos : 0;