Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
95aef915
Commit
95aef915
authored
Oct 25, 2002
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BINARY charset is now used instead of binary_flag
parent
0ca3212a
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
199 additions
and
226 deletions
+199
-226
include/mysql_com.h
include/mysql_com.h
+1
-1
mysql-test/r/range.result
mysql-test/r/range.result
+1
-1
sql/field.cc
sql/field.cc
+26
-43
sql/field.h
sql/field.h
+22
-51
sql/filesort.cc
sql/filesort.cc
+3
-3
sql/ha_innodb.cc
sql/ha_innodb.cc
+2
-2
sql/item.cc
sql/item.cc
+6
-12
sql/item.h
sql/item.h
+5
-3
sql/item_buff.cc
sql/item_buff.cc
+1
-1
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+24
-18
sql/item_func.cc
sql/item_func.cc
+20
-23
sql/item_strfunc.cc
sql/item_strfunc.cc
+20
-18
sql/item_strfunc.h
sql/item_strfunc.h
+11
-3
sql/item_sum.cc
sql/item_sum.cc
+3
-4
sql/sql_analyse.cc
sql/sql_analyse.cc
+5
-5
sql/sql_analyse.h
sql/sql_analyse.h
+1
-1
sql/sql_class.cc
sql/sql_class.cc
+1
-1
sql/sql_select.cc
sql/sql_select.cc
+7
-9
sql/sql_select.h
sql/sql_select.h
+1
-1
sql/sql_string.cc
sql/sql_string.cc
+15
-4
sql/sql_table.cc
sql/sql_table.cc
+8
-7
sql/sql_update.cc
sql/sql_update.cc
+1
-2
sql/sql_yacc.yy
sql/sql_yacc.yy
+12
-12
sql/table.cc
sql/table.cc
+2
-1
sql/unireg.cc
sql/unireg.cc
+1
-0
No files found.
include/mysql_com.h
View file @
95aef915
...
...
@@ -51,7 +51,7 @@ enum enum_server_command
#define BLOB_FLAG 16
/* Field is a blob */
#define UNSIGNED_FLAG 32
/* Field is unsigned */
#define ZEROFILL_FLAG 64
/* Field is zerofill */
#define BINARY_FLAG 128
/* The following are only sent to new clients */
#define ENUM_FLAG 256
/* field is an enum */
#define AUTO_INCREMENT_FLAG 512
/* field is a autoincrement field */
...
...
mysql-test/r/range.result
View file @
95aef915
...
...
@@ -193,7 +193,7 @@ INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j');
select count(*) from t1 where upper(art) = 'J';
count(*)
602
213
select count(*) from t1 where art = 'J' or art = 'j';
count(*)
602
...
...
sql/field.cc
View file @
95aef915
...
...
@@ -3734,10 +3734,9 @@ void Field_datetime::sql_type(String &res) const
int
Field_string
::
store
(
const
char
*
from
,
uint
length
,
CHARSET_INFO
*
cs
)
{
field_charset
=
cs
;
int
error
=
0
;
#ifdef USE_TIS620
if
(
!
binary
_flag
)
{
if
(
!
binary
()
)
{
ThNormalize
((
uchar
*
)
ptr
,
field_length
,
(
uchar
*
)
from
,
length
);
if
(
length
<
field_length
)
{
bfill
(
ptr
+
length
,
field_length
-
length
,
' '
);
...
...
@@ -3828,9 +3827,6 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)),
int
Field_string
::
cmp
(
const
char
*
a_ptr
,
const
char
*
b_ptr
)
{
if
(
binary_flag
)
return
memcmp
(
a_ptr
,
b_ptr
,
field_length
);
else
return
my_strnncoll
(
field_charset
,
(
const
uchar
*
)
a_ptr
,
field_length
,
(
const
uchar
*
)
b_ptr
,
field_length
);
...
...
@@ -3838,7 +3834,7 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr)
void
Field_string
::
sort_string
(
char
*
to
,
uint
length
)
{
if
(
binary
_flag
)
if
(
binary
()
)
memcpy
((
byte
*
)
to
,(
byte
*
)
ptr
,(
size_t
)
length
);
else
{
...
...
@@ -3868,7 +3864,7 @@ void Field_string::sql_type(String &res) const
"varchar"
:
"char"
),
(
int
)
field_length
));
res
.
length
((
uint
)
length
);
if
(
binary
_flag
)
if
(
binary
()
)
res
.
append
(
" binary"
);
else
{
...
...
@@ -3904,7 +3900,7 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length)
uint
a_length
=
(
uint
)
(
uchar
)
*
a
++
;
uint
b_length
=
(
uint
)
(
uchar
)
*
b
++
;
if
(
binary
_flag
)
if
(
binary
()
)
{
int
cmp
=
memcmp
(
a
,
b
,
min
(
a_length
,
b_length
));
return
cmp
?
cmp
:
(
int
)
(
a_length
-
b_length
);
...
...
@@ -3923,7 +3919,7 @@ int Field_string::pack_cmp(const char *b, uint length)
end
--
;
uint
a_length
=
(
uint
)
(
end
-
ptr
);
if
(
binary
_flag
)
if
(
binary
()
)
{
int
cmp
=
memcmp
(
ptr
,
b
,
min
(
a_length
,
b_length
));
return
cmp
?
cmp
:
(
int
)
(
a_length
-
b_length
);
...
...
@@ -3956,9 +3952,8 @@ uint Field_string::max_packed_col_length(uint max_length)
int
Field_varstring
::
store
(
const
char
*
from
,
uint
length
,
CHARSET_INFO
*
cs
)
{
int
error
=
0
;
field_charset
=
cs
;
#ifdef USE_TIS620
if
(
!
binary
_flag
)
if
(
!
binary
()
)
{
ThNormalize
((
uchar
*
)
ptr
+
2
,
field_length
,
(
uchar
*
)
from
,
length
);
}
...
...
@@ -4036,10 +4031,7 @@ int Field_varstring::cmp(const char *a_ptr, const char *b_ptr)
uint
a_length
=
uint2korr
(
a_ptr
);
uint
b_length
=
uint2korr
(
b_ptr
);
int
diff
;
if
(
binary_flag
)
diff
=
memcmp
(
a_ptr
+
2
,
b_ptr
+
2
,
min
(
a_length
,
b_length
));
else
diff
=
my_strnncoll
(
field_charset
,
diff
=
my_strnncoll
(
field_charset
,
(
const
uchar
*
)
a_ptr
+
2
,
min
(
a_length
,
b_length
),
(
const
uchar
*
)
b_ptr
+
2
,
min
(
a_length
,
b_length
));
return
diff
?
diff
:
(
int
)
(
a_length
-
b_length
);
...
...
@@ -4048,7 +4040,7 @@ int Field_varstring::cmp(const char *a_ptr, const char *b_ptr)
void
Field_varstring
::
sort_string
(
char
*
to
,
uint
length
)
{
uint
tot_length
=
uint2korr
(
ptr
);
if
(
binary
_flag
)
if
(
binary
()
)
memcpy
((
byte
*
)
to
,(
byte
*
)
ptr
+
2
,(
size_t
)
tot_length
);
else
{
...
...
@@ -4080,7 +4072,7 @@ void Field_varstring::sql_type(String &res) const
((
char
*
)
res
.
ptr
(),
"varchar(%u)"
,
field_length
));
res
.
length
((
uint
)
length
);
if
(
binary
_flag
)
if
(
binary
()
)
res
.
append
(
" binary"
);
else
{
...
...
@@ -4137,7 +4129,7 @@ int Field_varstring::pack_cmp(const char *a, const char *b, uint key_length)
a_length
=
(
uint
)
(
uchar
)
*
a
++
;
b_length
=
(
uint
)
(
uchar
)
*
b
++
;
}
if
(
binary
_flag
)
if
(
binary
()
)
{
int
cmp
=
memcmp
(
a
,
b
,
min
(
a_length
,
b_length
));
return
cmp
?
cmp
:
(
int
)
(
a_length
-
b_length
);
...
...
@@ -4160,7 +4152,7 @@ int Field_varstring::pack_cmp(const char *b, uint key_length)
{
b_length
=
(
uint
)
(
uchar
)
*
b
++
;
}
if
(
binary
_flag
)
if
(
binary
()
)
{
int
cmp
=
memcmp
(
a
,
b
,
min
(
a_length
,
b_length
));
return
cmp
?
cmp
:
(
int
)
(
a_length
-
b_length
);
...
...
@@ -4192,15 +4184,13 @@ uint Field_varstring::max_packed_col_length(uint max_length)
Field_blob
::
Field_blob
(
char
*
ptr_arg
,
uchar
*
null_ptr_arg
,
uchar
null_bit_arg
,
enum
utype
unireg_check_arg
,
const
char
*
field_name_arg
,
struct
st_table
*
table_arg
,
uint
blob_pack_length
,
bool
binary_arg
,
CHARSET_INFO
*
cs
)
CHARSET_INFO
*
cs
)
:
Field_str
(
ptr_arg
,
(
1L
<<
min
(
blob_pack_length
,
3
)
*
8
)
-
1L
,
null_ptr_arg
,
null_bit_arg
,
unireg_check_arg
,
field_name_arg
,
table_arg
,
cs
),
packlength
(
blob_pack_length
),
binary_flag
(
binary_arg
),
geom_flag
(
true
)
packlength
(
blob_pack_length
),
geom_flag
(
true
)
{
flags
|=
BLOB_FLAG
;
if
(
binary_arg
)
flags
|=
BINARY_FLAG
;
if
(
table
)
table
->
blob_fields
++
;
}
...
...
@@ -4289,7 +4279,6 @@ uint32 Field_blob::get_length(const char *pos)
int
Field_blob
::
store
(
const
char
*
from
,
uint
len
,
CHARSET_INFO
*
cs
)
{
field_charset
=
cs
;
if
(
!
len
)
{
bzero
(
ptr
,
Field_blob
::
pack_length
());
...
...
@@ -4303,7 +4292,7 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
if
(
table
->
copy_blobs
||
len
<=
MAX_FIELD_WIDTH
)
{
// Must make a copy
#ifdef USE_TIS620
if
(
!
binary
_flag
)
if
(
!
binary
()
)
{
/* If there isn't enough memory, use original string */
if
((
th_ptr
=
(
char
*
)
my_malloc
(
sizeof
(
char
)
*
len
,
MYF
(
0
))))
...
...
@@ -4390,13 +4379,9 @@ String *Field_blob::val_str(String *val_buffer __attribute__((unused)),
int
Field_blob
::
cmp
(
const
char
*
a
,
uint32
a_length
,
const
char
*
b
,
uint32
b_length
)
{
int
diff
;
if
(
binary_flag
)
diff
=
memcmp
(
a
,
b
,
min
(
a_length
,
b_length
));
else
diff
=
my_strnncoll
(
field_charset
,
(
const
uchar
*
)
a
,
min
(
a_length
,
b_length
),
(
const
uchar
*
)
b
,
min
(
a_length
,
b_length
));
int
diff
=
my_strnncoll
(
field_charset
,
(
const
uchar
*
)
a
,
min
(
a_length
,
b_length
),
(
const
uchar
*
)
b
,
min
(
a_length
,
b_length
));
return
diff
?
diff
:
(
int
)
(
a_length
-
b_length
);
}
...
...
@@ -4542,7 +4527,7 @@ void Field_blob::sort_string(char *to,uint length)
if
(
blob_length
>
length
)
blob_length
=
length
;
memcpy_fixed
(
&
blob
,
ptr
+
packlength
,
sizeof
(
char
*
));
if
(
binary
_flag
)
if
(
binary
()
)
{
memcpy
(
to
,
blob
,
blob_length
);
to
+=
blob_length
;
...
...
@@ -4579,8 +4564,8 @@ void Field_blob::sql_type(String &res) const
case
4
:
str
=
"long"
;
break
;
}
res
.
set
(
str
,(
uint
)
strlen
(
str
),
default_charset_info
);
res
.
append
(
binary
_flag
?
"blob"
:
"text"
);
if
(
!
binary
_flag
)
res
.
append
(
binary
()
?
"blob"
:
"text"
);
if
(
!
binary
()
)
{
res
.
append
(
" character set "
);
res
.
append
(
field_charset
->
name
);
...
...
@@ -4640,7 +4625,7 @@ int Field_blob::pack_cmp(const char *a, const char *b, uint key_length)
a_length
=
(
uint
)
(
uchar
)
*
a
++
;
b_length
=
(
uint
)
(
uchar
)
*
b
++
;
}
if
(
binary
_flag
)
if
(
binary
()
)
{
int
cmp
=
memcmp
(
a
,
b
,
min
(
a_length
,
b_length
));
return
cmp
?
cmp
:
(
int
)
(
a_length
-
b_length
);
...
...
@@ -4668,7 +4653,7 @@ int Field_blob::pack_cmp(const char *b, uint key_length)
{
b_length
=
(
uint
)
(
uchar
)
*
b
++
;
}
if
(
binary
_flag
)
if
(
binary
()
)
{
int
cmp
=
memcmp
(
a
,
b
,
min
(
a_length
,
b_length
));
return
cmp
?
cmp
:
(
int
)
(
a_length
-
b_length
);
...
...
@@ -5187,6 +5172,7 @@ Field *make_field(char *ptr, uint32 field_length,
uchar
*
null_pos
,
uchar
null_bit
,
uint
pack_flag
,
enum_field_types
field_type
,
CHARSET_INFO
*
field_charset
,
Field
::
utype
unireg_check
,
TYPELIB
*
interval
,
const
char
*
field_name
,
...
...
@@ -5201,9 +5187,7 @@ Field *make_field(char *ptr, uint32 field_length,
{
if
(
!
f_is_packed
(
pack_flag
))
return
new
Field_string
(
ptr
,
field_length
,
null_pos
,
null_bit
,
unireg_check
,
field_name
,
table
,
f_is_binary
(
pack_flag
)
!=
0
,
default_charset_info
);
unireg_check
,
field_name
,
table
,
field_charset
);
uint
pack_length
=
calc_pack_length
((
enum_field_types
)
f_packtype
(
pack_flag
),
...
...
@@ -5212,12 +5196,11 @@ Field *make_field(char *ptr, uint32 field_length,
if
(
f_is_blob
(
pack_flag
))
return
new
Field_blob
(
ptr
,
null_pos
,
null_bit
,
unireg_check
,
field_name
,
table
,
pack_length
,
f_is_binary
(
pack_flag
)
!=
0
,
default_charset_info
);
pack_length
,
field_charset
);
if
(
f_is_geom
(
pack_flag
))
return
new
Field_geom
(
ptr
,
null_pos
,
null_bit
,
unireg_check
,
field_name
,
table
,
pack_length
,
f_is_binary
(
pack_flag
)
!=
0
);
pack_length
);
if
(
interval
)
{
...
...
sql/field.h
View file @
95aef915
...
...
@@ -129,7 +129,7 @@ class Field {
tmp
->
table
=
new_table
;
tmp
->
key_start
=
tmp
->
part_of_key
=
tmp
->
part_of_sortkey
=
0
;
tmp
->
unireg_check
=
Field
::
NONE
;
tmp
->
flags
&=
(
NOT_NULL_FLAG
|
BLOB_FLAG
|
UNSIGNED_FLAG
|
ZEROFILL_FLAG
|
BINARY_FLAG
|
ENUM_FLAG
|
SET_FLAG
);
tmp
->
flags
&=
(
NOT_NULL_FLAG
|
BLOB_FLAG
|
UNSIGNED_FLAG
|
ZEROFILL_FLAG
|
ENUM_FLAG
|
SET_FLAG
);
tmp
->
reset_fields
();
}
return
tmp
;
...
...
@@ -198,7 +198,7 @@ class Field {
uint
fill_cache_field
(
struct
st_cache_field
*
copy
);
virtual
bool
get_date
(
TIME
*
ltime
,
bool
fuzzydate
);
virtual
bool
get_time
(
TIME
*
ltime
);
virtual
CHARSET_INFO
*
charset
(
void
)
{
return
0
;
}
virtual
CHARSET_INFO
*
charset
(
void
)
{
return
my_charset_bin
;
}
friend
bool
reopen_table
(
THD
*
,
struct
st_table
*
,
bool
);
friend
int
cre_myisam
(
my_string
name
,
register
TABLE
*
form
,
uint
options
,
ulonglong
auto_increment_value
);
...
...
@@ -263,6 +263,7 @@ class Field_str :public Field {
CHARSET_INFO
*
charset
(
void
)
{
return
field_charset
;
}
inline
void
set_charset
(
CHARSET_INFO
*
charset
)
{
field_charset
=
charset
;
}
bool
binary
()
const
{
return
field_charset
->
state
&
MY_CS_BINSORT
?
1
:
0
;
}
inline
int
cmp_image
(
char
*
buff
,
uint
length
)
{
if
(
binary
())
...
...
@@ -740,28 +741,17 @@ class Field_datetime :public Field_str {
class
Field_string
:
public
Field_str
{
bool
binary_flag
;
public:
Field_string
(
char
*
ptr_arg
,
uint32
len_arg
,
uchar
*
null_ptr_arg
,
uchar
null_bit_arg
,
enum
utype
unireg_check_arg
,
const
char
*
field_name_arg
,
struct
st_table
*
table_arg
,
bool
binary_arg
,
CHARSET_INFO
*
cs
)
struct
st_table
*
table_arg
,
CHARSET_INFO
*
cs
)
:
Field_str
(
ptr_arg
,
len_arg
,
null_ptr_arg
,
null_bit_arg
,
unireg_check_arg
,
field_name_arg
,
table_arg
,
cs
),
binary_flag
(
binary_arg
)
{
if
(
binary_arg
)
flags
|=
BINARY_FLAG
;
}
unireg_check_arg
,
field_name_arg
,
table_arg
,
cs
)
{};
Field_string
(
uint32
len_arg
,
bool
maybe_null_arg
,
const
char
*
field_name_arg
,
struct
st_table
*
table_arg
,
bool
binary_arg
,
CHARSET_INFO
*
cs
)
struct
st_table
*
table_arg
,
CHARSET_INFO
*
cs
)
:
Field_str
((
char
*
)
0
,
len_arg
,
maybe_null_arg
?
(
uchar
*
)
""
:
0
,
0
,
NONE
,
field_name_arg
,
table_arg
,
cs
),
binary_flag
(
binary_arg
)
{
if
(
binary_arg
)
flags
|=
BINARY_FLAG
;
}
NONE
,
field_name_arg
,
table_arg
,
cs
)
{};
enum_field_types
type
()
const
{
...
...
@@ -770,9 +760,8 @@ class Field_string :public Field_str {
FIELD_TYPE_VAR_STRING
:
FIELD_TYPE_STRING
);
}
enum
ha_base_keytype
key_type
()
const
{
return
binary
_flag
?
HA_KEYTYPE_BINARY
:
HA_KEYTYPE_TEXT
;
}
{
return
binary
()
?
HA_KEYTYPE_BINARY
:
HA_KEYTYPE_TEXT
;
}
bool
zero_pack
()
const
{
return
0
;
}
bool
binary
()
const
{
return
binary_flag
;
}
void
reset
(
void
)
{
bfill
(
ptr
,
field_length
,
' '
);
}
int
store
(
const
char
*
to
,
uint
length
,
CHARSET_INFO
*
charset
);
int
store
(
double
nr
);
...
...
@@ -795,34 +784,22 @@ class Field_string :public Field_str {
class
Field_varstring
:
public
Field_str
{
bool
binary_flag
;
public:
Field_varstring
(
char
*
ptr_arg
,
uint32
len_arg
,
uchar
*
null_ptr_arg
,
uchar
null_bit_arg
,
enum
utype
unireg_check_arg
,
const
char
*
field_name_arg
,
struct
st_table
*
table_arg
,
bool
binary_arg
,
CHARSET_INFO
*
cs
)
struct
st_table
*
table_arg
,
CHARSET_INFO
*
cs
)
:
Field_str
(
ptr_arg
,
len_arg
,
null_ptr_arg
,
null_bit_arg
,
unireg_check_arg
,
field_name_arg
,
table_arg
,
cs
),
binary_flag
(
binary_arg
)
{
if
(
binary_arg
)
flags
|=
BINARY_FLAG
;
}
unireg_check_arg
,
field_name_arg
,
table_arg
,
cs
)
{};
Field_varstring
(
uint32
len_arg
,
bool
maybe_null_arg
,
const
char
*
field_name_arg
,
struct
st_table
*
table_arg
,
bool
binary_arg
,
CHARSET_INFO
*
cs
)
struct
st_table
*
table_arg
,
CHARSET_INFO
*
cs
)
:
Field_str
((
char
*
)
0
,
len_arg
,
maybe_null_arg
?
(
uchar
*
)
""
:
0
,
0
,
NONE
,
field_name_arg
,
table_arg
,
cs
),
binary_flag
(
binary_arg
)
{
if
(
binary_arg
)
flags
|=
BINARY_FLAG
;
}
NONE
,
field_name_arg
,
table_arg
,
cs
)
{};
enum_field_types
type
()
const
{
return
FIELD_TYPE_VAR_STRING
;
}
enum
ha_base_keytype
key_type
()
const
{
return
binary
_flag
?
HA_KEYTYPE_VARBINARY
:
HA_KEYTYPE_VARTEXT
;
}
{
return
binary
()
?
HA_KEYTYPE_VARBINARY
:
HA_KEYTYPE_VARTEXT
;
}
bool
zero_pack
()
const
{
return
0
;
}
bool
binary
()
const
{
return
binary_flag
;
}
void
reset
(
void
)
{
bzero
(
ptr
,
field_length
+
2
);
}
uint32
pack_length
()
const
{
return
(
uint32
)
field_length
+
2
;
}
uint32
key_length
()
const
{
return
(
uint32
)
field_length
;
}
...
...
@@ -849,26 +826,23 @@ class Field_varstring :public Field_str {
class
Field_blob
:
public
Field_str
{
uint
packlength
;
String
value
;
// For temporaries
bool
binary_flag
;
bool
geom_flag
;
public:
Field_blob
(
char
*
ptr_arg
,
uchar
*
null_ptr_arg
,
uchar
null_bit_arg
,
enum
utype
unireg_check_arg
,
const
char
*
field_name_arg
,
struct
st_table
*
table_arg
,
uint
blob_pack_length
,
bool
binary_arg
,
CHARSET_INFO
*
cs
);
CHARSET_INFO
*
cs
);
Field_blob
(
uint32
len_arg
,
bool
maybe_null_arg
,
const
char
*
field_name_arg
,
struct
st_table
*
table_arg
,
bool
binary_arg
,
CHARSET_INFO
*
cs
)
struct
st_table
*
table_arg
,
CHARSET_INFO
*
cs
)
:
Field_str
((
char
*
)
0
,
len_arg
,
maybe_null_arg
?
(
uchar
*
)
""
:
0
,
0
,
NONE
,
field_name_arg
,
table_arg
,
cs
),
packlength
(
3
),
binary_flag
(
binary_arg
),
geom_flag
(
true
)
packlength
(
3
),
geom_flag
(
true
)
{
flags
|=
BLOB_FLAG
;
if
(
binary_arg
)
flags
|=
BINARY_FLAG
;
}
enum_field_types
type
()
const
{
return
FIELD_TYPE_BLOB
;}
enum
ha_base_keytype
key_type
()
const
{
return
binary
_flag
?
HA_KEYTYPE_VARBINARY
:
HA_KEYTYPE_VARTEXT
;
}
{
return
binary
()
?
HA_KEYTYPE_VARBINARY
:
HA_KEYTYPE_VARTEXT
;
}
int
store
(
const
char
*
to
,
uint
length
,
CHARSET_INFO
*
charset
);
int
store
(
double
nr
);
int
store
(
longlong
nr
);
...
...
@@ -892,7 +866,6 @@ class Field_blob :public Field_str {
inline
uint32
get_length
(
uint
row_offset
=
0
)
{
return
get_length
(
ptr
+
row_offset
);
}
uint32
get_length
(
const
char
*
ptr
);
bool
binary
()
const
{
return
binary_flag
;
}
inline
void
get_ptr
(
char
**
str
)
{
memcpy_fixed
(
str
,
ptr
+
packlength
,
sizeof
(
char
*
));
...
...
@@ -940,15 +913,13 @@ class Field_geom :public Field_blob {
public:
Field_geom
(
char
*
ptr_arg
,
uchar
*
null_ptr_arg
,
uint
null_bit_arg
,
enum
utype
unireg_check_arg
,
const
char
*
field_name_arg
,
struct
st_table
*
table_arg
,
uint
blob_pack_length
,
bool
binary_arg
)
struct
st_table
*
table_arg
,
uint
blob_pack_length
)
:
Field_blob
(
ptr_arg
,
null_ptr_arg
,
null_bit_arg
,
unireg_check_arg
,
field_name_arg
,
table_arg
,
blob_pack_length
,
binary_arg
,
default_charset_info
)
{}
field_name_arg
,
table_arg
,
blob_pack_length
,
my_charset_bin
)
{}
Field_geom
(
uint32
len_arg
,
bool
maybe_null_arg
,
const
char
*
field_name_arg
,
struct
st_table
*
table_arg
,
bool
binary_arg
)
struct
st_table
*
table_arg
)
:
Field_blob
(
len_arg
,
maybe_null_arg
,
field_name_arg
,
table_arg
,
binary_arg
,
default_charset_info
)
{}
table_arg
,
my_charset_bin
)
{}
enum
ha_base_keytype
key_type
()
const
{
return
HA_KEYTYPE_VARBINARY
;
}
void
get_key_image
(
char
*
buff
,
uint
length
,
imagetype
type
);
...
...
@@ -1088,6 +1059,7 @@ class Copy_field :public Sql_alloc {
Field
*
make_field
(
char
*
ptr
,
uint32
field_length
,
uchar
*
null_pos
,
uchar
null_bit
,
uint
pack_flag
,
enum_field_types
field_type
,
CHARSET_INFO
*
cs
,
Field
::
utype
unireg_check
,
TYPELIB
*
interval
,
const
char
*
field_name
,
struct
st_table
*
table
);
...
...
@@ -1135,7 +1107,6 @@ bool test_if_int(const char *str,int length);
#define f_packtype(x) (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
#define f_decimals(x) ((uint8) (((x) >> FIELDFLAG_DEC_SHIFT) & FIELDFLAG_MAX_DEC))
#define f_is_alpha(x) (!f_is_num(x))
#define f_is_binary(x) ((x) & FIELDFLAG_BINARY)
#define f_is_enum(x) ((x) & FIELDFLAG_INTERVAL)
#define f_is_bitfield(x) ((x) & FIELDFLAG_BITFIELD)
#define f_is_blob(x) (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == FIELDFLAG_BLOB)
...
...
sql/filesort.cc
View file @
95aef915
...
...
@@ -498,7 +498,7 @@ static void make_sortkey(register SORTPARAM *param,
#ifdef USE_STRCOLL
if
(
use_strnxfrm
(
cs
))
{
if
(
item
->
binary
)
if
(
item
->
binary
()
)
{
if
(
res
->
ptr
()
!=
(
char
*
)
to
)
memcpy
(
to
,
res
->
ptr
(),
length
);
...
...
@@ -525,7 +525,7 @@ static void make_sortkey(register SORTPARAM *param,
if
(
res
->
ptr
()
!=
(
char
*
)
to
)
memcpy
(
to
,
res
->
ptr
(),
length
);
bzero
((
char
*
)
to
+
length
,
diff
);
if
(
!
item
->
binary
)
if
(
!
item
->
binary
()
)
my_tosort
(
cs
,
(
char
*
)
to
,
length
);
#ifdef USE_STRCOLL
}
...
...
@@ -948,7 +948,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
case
STRING_RESULT
:
sortorder
->
length
=
sortorder
->
item
->
max_length
;
#ifdef USE_STRCOLL
if
(
!
sortorder
->
item
->
binary
)
if
(
!
sortorder
->
item
->
binary
()
)
{
CHARSET_INFO
*
cs
=
sortorder
->
item
->
str_value
.
charset
();
if
(
use_strnxfrm
(
cs
))
...
...
sql/ha_innodb.cc
View file @
95aef915
...
...
@@ -1404,7 +1404,7 @@ get_innobase_type_from_mysql_type(
DBUG_ASSERT
((
ulint
)
FIELD_TYPE_DECIMAL
<
256
);
switch
(
field
->
type
())
{
case
FIELD_TYPE_VAR_STRING
:
if
(
field
->
flags
&
BINARY_FLAG
)
{
case
FIELD_TYPE_VAR_STRING
:
if
(
field
->
binary
()
)
{
return
(
DATA_BINARY
);
}
else
if
(
strcmp
(
...
...
@@ -1414,7 +1414,7 @@ get_innobase_type_from_mysql_type(
}
else
{
return
(
DATA_VARMYSQL
);
}
case
FIELD_TYPE_STRING
:
if
(
field
->
flags
&
BINARY_FLAG
)
{
case
FIELD_TYPE_STRING
:
if
(
field
->
binary
()
)
{
return
(
DATA_FIXBINARY
);
}
else
if
(
strcmp
(
...
...
sql/item.cc
View file @
95aef915
...
...
@@ -37,7 +37,7 @@ void item_init(void)
Item
::
Item
()
{
marker
=
0
;
binary
=
maybe_null
=
null_value
=
with_sum_func
=
unsigned_flag
=
0
;
maybe_null
=
null_value
=
with_sum_func
=
unsigned_flag
=
0
;
name
=
0
;
decimals
=
0
;
max_length
=
0
;
next
=
current_thd
->
free_list
;
// Put in free list
...
...
@@ -131,11 +131,8 @@ void Item_field::set_field(Field *field_par)
decimals
=
field
->
decimals
();
table_name
=
field_par
->
table_name
;
field_name
=
field_par
->
field_name
;
binary
=
field_par
->
binary
();
unsigned_flag
=
test
(
field_par
->
flags
&
UNSIGNED_FLAG
);
/* For string fields copy character set from original field */
if
(
!
field_par
->
binary
())
str_value
.
set_charset
(((
Field_str
*
)
field_par
)
->
charset
());
str_value
.
set_charset
(
field_par
->
charset
());
}
const
char
*
Item_ident
::
full_name
()
const
...
...
@@ -670,7 +667,7 @@ int Item::save_in_field(Field *field)
field
->
result_type
()
==
STRING_RESULT
)
{
String
*
result
;
CHARSET_INFO
*
cs
=
field
->
binary
()
?
default_charset_info
:
((
Field_str
*
)
field
)
->
charset
();
CHARSET_INFO
*
cs
=
field
->
binary
()
?
my_charset_bin
:
((
Field_str
*
)
field
)
->
charset
();
char
buff
[
MAX_FIELD_WIDTH
];
// Alloc buffer for small columns
str_value
.
set_quick
(
buff
,
sizeof
(
buff
),
cs
);
result
=
val_str
(
&
str_value
);
...
...
@@ -702,7 +699,7 @@ int Item::save_in_field(Field *field)
int
Item_string
::
save_in_field
(
Field
*
field
)
{
String
*
result
;
CHARSET_INFO
*
cs
=
field
->
binary
()
?
default_charset_info
:
((
Field_str
*
)
field
)
->
charset
();
CHARSET_INFO
*
cs
=
field
->
binary
()
?
my_charset_bin
:
((
Field_str
*
)
field
)
->
charset
();
result
=
val_str
(
&
str_value
);
if
(
null_value
)
return
set_field_to_null
(
field
);
...
...
@@ -741,15 +738,14 @@ inline uint char_val(char X)
X
-
'a'
+
10
);
}
Item_varbinary
::
Item_varbinary
(
const
char
*
str
,
uint
str_length
,
CHARSET_INFO
*
cs
)
Item_varbinary
::
Item_varbinary
(
const
char
*
str
,
uint
str_length
)
{
name
=
(
char
*
)
str
-
2
;
// Lex makes this start with 0x
max_length
=
(
str_length
+
1
)
/
2
;
char
*
ptr
=
(
char
*
)
sql_alloc
(
max_length
+
1
);
if
(
!
ptr
)
return
;
str_value
.
set
(
ptr
,
max_length
,
cs
);
str_value
.
set
(
ptr
,
max_length
,
my_charset_bin
);
char
*
end
=
ptr
+
max_length
;
if
(
max_length
*
2
!=
str_length
)
*
ptr
++=
char_val
(
*
str
++
);
// Not even, assume 0 prefix
...
...
@@ -759,7 +755,6 @@ Item_varbinary::Item_varbinary(const char *str, uint str_length,
str
+=
2
;
}
*
ptr
=
0
;
// Keep purify happy
binary
=
1
;
// Binary is default
}
longlong
Item_varbinary
::
val_int
()
...
...
@@ -887,7 +882,6 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
max_length
=
(
*
ref
)
->
max_length
;
maybe_null
=
(
*
ref
)
->
maybe_null
;
decimals
=
(
*
ref
)
->
decimals
;
binary
=
(
*
ref
)
->
binary
;
}
return
0
;
}
...
...
sql/item.h
View file @
95aef915
...
...
@@ -43,7 +43,6 @@ class Item {
uint8
marker
,
decimals
;
my_bool
maybe_null
;
/* If item may be null */
my_bool
null_value
;
/* if item is null */
my_bool
binary
;
my_bool
unsigned_flag
;
my_bool
with_sum_func
;
...
...
@@ -84,7 +83,10 @@ class Item {
virtual
void
split_sum_func
(
List
<
Item
>
&
fields
)
{}
virtual
bool
get_date
(
TIME
*
ltime
,
bool
fuzzydate
);
virtual
bool
get_time
(
TIME
*
ltime
);
virtual
bool
is_null
()
{
return
0
;
}
virtual
bool
is_null
()
{
return
0
;
};
virtual
CHARSET_INFO
*
charset
()
const
{
return
str_value
.
charset
();
};
virtual
bool
binary
()
const
{
return
str_value
.
charset
()
->
state
&
MY_CS_BINSORT
?
1
:
0
;
}
virtual
void
set_charset
(
CHARSET_INFO
*
cs
)
{
str_value
.
set_charset
(
cs
);
}
};
...
...
@@ -361,7 +363,7 @@ class Item_empty_string :public Item_string
class
Item_varbinary
:
public
Item
{
public:
Item_varbinary
(
const
char
*
str
,
uint
str_length
,
CHARSET_INFO
*
cs
);
Item_varbinary
(
const
char
*
str
,
uint
str_length
);
~
Item_varbinary
()
{}
enum
Type
type
()
const
{
return
VARBIN_ITEM
;
}
double
val
()
{
return
(
double
)
Item_varbinary
::
val_int
();
}
...
...
sql/item_buff.cc
View file @
95aef915
...
...
@@ -56,7 +56,7 @@ bool Item_str_buff::cmp(void)
}
else
if
(
null_value
)
return
0
;
// new and old value was null
else
if
(
!
item
->
binary
)
else
if
(
!
item
->
binary
()
)
tmp
=
sortcmp
(
&
value
,
res
)
!=
0
;
else
tmp
=
stringcmp
(
&
value
,
res
)
!=
0
;
...
...
sql/item_cmpfunc.cc
View file @
95aef915
...
...
@@ -128,7 +128,7 @@ int Item_bool_func2::compare_string()
if
((
res2
=
args
[
1
]
->
val_str
(
&
tmp_value2
)))
{
null_value
=
0
;
return
binary
?
stringcmp
(
res1
,
res2
)
:
sortcmp
(
res1
,
res2
);
return
binary
()
?
stringcmp
(
res1
,
res2
)
:
sortcmp
(
res1
,
res2
);
}
}
null_value
=
1
;
...
...
@@ -199,7 +199,7 @@ longlong Item_func_equal::val_int()
res2
=
args
[
1
]
->
val_str
(
&
tmp_value2
);
if
(
!
res1
||
!
res2
)
return
test
(
res1
==
res2
);
return
(
binary
?
test
(
stringcmp
(
res1
,
res2
)
==
0
)
:
return
(
binary
()
?
test
(
stringcmp
(
res1
,
res2
)
==
0
)
:
test
(
sortcmp
(
res1
,
res2
)
==
0
));
}
case
REAL_RESULT
:
...
...
@@ -266,7 +266,7 @@ longlong Item_func_strcmp::val_int()
null_value
=
1
;
return
0
;
}
int
value
=
binary
?
stringcmp
(
a
,
b
)
:
sortcmp
(
a
,
b
);
int
value
=
binary
()
?
stringcmp
(
a
,
b
)
:
sortcmp
(
a
,
b
);
null_value
=
0
;
return
!
value
?
0
:
(
value
<
0
?
(
longlong
)
-
1
:
(
longlong
)
1
);
}
...
...
@@ -355,7 +355,7 @@ void Item_func_between::fix_length_and_dec()
if
(
!
args
[
0
]
||
!
args
[
1
]
||
!
args
[
2
])
return
;
cmp_type
=
args
[
0
]
->
result_type
();
if
(
args
[
0
]
->
binary
)
if
(
args
[
0
]
->
binary
()
)
string_compare
=
stringcmp
;
else
string_compare
=
sortcmp
;
...
...
@@ -511,21 +511,22 @@ Item_func_if::fix_length_and_dec()
if
(
null1
)
{
cached_result_type
=
arg2_type
;
binary
=
args
[
2
]
->
binary
;
set_charset
(
args
[
2
]
->
charset
())
;
}
else
if
(
null2
)
{
cached_result_type
=
arg1_type
;
binary
=
args
[
1
]
->
binary
;
set_charset
(
args
[
1
]
->
charset
())
;
}
else
if
(
arg1_type
==
STRING_RESULT
||
arg2_type
==
STRING_RESULT
)
{
cached_result_type
=
STRING_RESULT
;
binary
=
args
[
1
]
->
binary
|
args
[
2
]
->
binary
;
set_charset
(
(
args
[
1
]
->
binary
()
||
args
[
2
]
->
binary
())
?
my_charset_bin
:
args
[
1
]
->
charset
());
}
else
{
binary
=
1
;
// Number
set_charset
(
my_charset_bin
);
// Number
if
(
arg1_type
==
REAL_RESULT
||
arg2_type
==
REAL_RESULT
)
cached_result_type
=
REAL_RESULT
;
else
...
...
@@ -663,7 +664,7 @@ Item *Item_func_case::find_item(String *str)
}
if
((
tmp
=
args
[
i
]
->
val_str
(
str
)))
// If not null
{
if
(
first_expr
->
binary
||
args
[
i
]
->
binary
)
if
(
first_expr
->
binary
()
||
args
[
i
]
->
binary
()
)
{
if
(
stringcmp
(
tmp
,
first_expr_str
)
==
0
)
return
args
[
i
+
1
];
...
...
@@ -977,7 +978,7 @@ void Item_func_in::fix_length_and_dec()
{
switch
(
item
->
result_type
())
{
case
STRING_RESULT
:
if
(
item
->
binary
)
if
(
item
->
binary
()
)
array
=
new
in_string
(
arg_count
,(
qsort_cmp
)
stringcmp
);
/* purecov: inspected */
else
array
=
new
in_string
(
arg_count
,(
qsort_cmp
)
sortcmp
);
...
...
@@ -1003,7 +1004,7 @@ void Item_func_in::fix_length_and_dec()
{
switch
(
item
->
result_type
())
{
case
STRING_RESULT
:
if
(
item
->
binary
)
if
(
item
->
binary
()
)
in_item
=
new
cmp_item_binary_string
;
else
in_item
=
new
cmp_item_sort_string
;
...
...
@@ -1275,9 +1276,12 @@ longlong Item_func_like::val_int()
return
0
;
}
null_value
=
0
;
if
((
res
->
charset
()
->
state
&
MY_CS_BINSORT
)
||
(
res2
->
charset
()
->
state
&
MY_CS_BINSORT
))
set_charset
(
my_charset_bin
);
if
(
canDoTurboBM
)
return
turboBM_matches
(
res
->
ptr
(),
res
->
length
())
?
1
:
0
;
if
(
binary
)
if
(
binary
()
)
return
wild_compare
(
*
res
,
*
res2
,
escape
)
?
0
:
1
;
else
return
wild_case_compare
(
*
res
,
*
res2
,
escape
)
?
0
:
1
;
...
...
@@ -1359,7 +1363,9 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return
1
;
/* purecov: inspected */
with_sum_func
=
args
[
0
]
->
with_sum_func
||
args
[
1
]
->
with_sum_func
;
max_length
=
1
;
decimals
=
0
;
binary
=
args
[
0
]
->
binary
||
args
[
1
]
->
binary
;
if
(
args
[
0
]
->
binary
()
||
args
[
1
]
->
binary
())
set_charset
(
my_charset_bin
);
used_tables_cache
=
args
[
0
]
->
used_tables
()
|
args
[
1
]
->
used_tables
();
const_item_cache
=
args
[
0
]
->
const_item
()
&&
args
[
1
]
->
const_item
();
if
(
!
regex_compiled
&&
args
[
1
]
->
const_item
())
...
...
@@ -1374,7 +1380,7 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
}
int
error
;
if
((
error
=
regcomp
(
&
preg
,
res
->
c_ptr
(),
binary
?
REG_EXTENDED
|
REG_NOSUB
:
binary
()
?
REG_EXTENDED
|
REG_NOSUB
:
REG_EXTENDED
|
REG_NOSUB
|
REG_ICASE
,
res
->
charset
())))
{
...
...
@@ -1421,7 +1427,7 @@ longlong Item_func_regex::val_int()
regex_compiled
=
0
;
}
if
(
regcomp
(
&
preg
,
res2
->
c_ptr
(),
binary
?
REG_EXTENDED
|
REG_NOSUB
:
binary
()
?
REG_EXTENDED
|
REG_NOSUB
:
REG_EXTENDED
|
REG_NOSUB
|
REG_ICASE
,
res
->
charset
()))
...
...
@@ -1471,7 +1477,7 @@ void Item_func_like::turboBM_compute_suffixes(int* suff)
*
splm1
=
pattern_len
;
if
(
binary
)
if
(
binary
()
)
{
int
i
;
for
(
i
=
pattern_len
-
2
;
i
>=
0
;
i
--
)
...
...
@@ -1574,7 +1580,7 @@ void Item_func_like::turboBM_compute_bad_character_shifts()
for
(
i
=
bmBc
;
i
<
end
;
i
++
)
*
i
=
pattern_len
;
if
(
binary
)
if
(
binary
()
)
{
for
(
j
=
0
;
j
<
plm1
;
j
++
)
bmBc
[
pattern
[
j
]]
=
plm1
-
j
;
...
...
@@ -1605,7 +1611,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
const
int
tlmpl
=
text_len
-
pattern_len
;
/* Searching */
if
(
binary
)
if
(
binary
()
)
{
while
(
j
<=
tlmpl
)
{
...
...
sql/item_func.cc
View file @
95aef915
...
...
@@ -75,7 +75,6 @@ Item_func::Item_func(List<Item> &list)
Sets as a side effect the following class variables:
maybe_null Set if any argument may return NULL
binary Set if any of the arguments is binary
with_sum_func Set if any of the arguments contains a sum function
used_table_cache Set to union of the arguments used table
...
...
@@ -97,7 +96,6 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{
Item
**
arg
,
**
arg_end
;
char
buff
[
STACK_BUFF_ALLOC
];
// Max argument in function
binary
=
0
;
used_tables_cache
=
0
;
const_item_cache
=
1
;
...
...
@@ -105,24 +103,24 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return
0
;
// Fatal error if flag is set!
if
(
arg_count
)
{
// Print purify happy
/*
Set return character set to first argument if we are returning a
string.
*/
if
(
result_type
()
==
STRING_RESULT
)
set_charset
((
*
args
)
->
charset
());
for
(
arg
=
args
,
arg_end
=
args
+
arg_count
;
arg
!=
arg_end
;
arg
++
)
{
if
((
*
arg
)
->
fix_fields
(
thd
,
tables
,
arg
))
return
1
;
/* purecov: inspected */
if
((
*
arg
)
->
maybe_null
)
maybe_null
=
1
;
if
((
*
arg
)
->
binary
)
binary
=
1
;
if
((
*
arg
)
->
binary
()
)
set_charset
(
my_charset_bin
)
;
with_sum_func
=
with_sum_func
||
(
*
arg
)
->
with_sum_func
;
used_tables_cache
|=
(
*
arg
)
->
used_tables
();
const_item_cache
&=
(
*
arg
)
->
const_item
();
}
/*
Set return character set to first argument if we are returning a
string.
*/
if
(
result_type
()
==
STRING_RESULT
)
str_value
.
set_charset
((
*
args
)
->
str_value
.
charset
());
}
fix_length_and_dec
();
return
0
;
...
...
@@ -230,10 +228,10 @@ Field *Item_func::tmp_table_field(TABLE *t_arg)
break
;
case
STRING_RESULT
:
if
(
max_length
>
255
)
res
=
new
Field_blob
(
max_length
,
maybe_null
,
name
,
t_arg
,
binary
,
res
=
new
Field_blob
(
max_length
,
maybe_null
,
name
,
t_arg
,
str_value
.
charset
());
else
res
=
new
Field_string
(
max_length
,
maybe_null
,
name
,
t_arg
,
binary
,
res
=
new
Field_string
(
max_length
,
maybe_null
,
name
,
t_arg
,
str_value
.
charset
());
break
;
}
...
...
@@ -778,7 +776,6 @@ void Item_func_min_max::fix_length_and_dec()
decimals
=
0
;
max_length
=
0
;
maybe_null
=
1
;
binary
=
0
;
cmp_type
=
args
[
0
]
->
result_type
();
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
...
...
@@ -789,8 +786,8 @@ void Item_func_min_max::fix_length_and_dec()
if
(
!
args
[
i
]
->
maybe_null
)
maybe_null
=
0
;
cmp_type
=
item_cmp_type
(
cmp_type
,
args
[
i
]
->
result_type
());
if
(
args
[
i
]
->
binary
)
binary
=
1
;
if
(
args
[
i
]
->
binary
()
)
set_charset
(
my_charset_bin
)
;
}
}
...
...
@@ -836,7 +833,7 @@ String *Item_func_min_max::val_str(String *str)
res2
=
args
[
i
]
->
val_str
(
res
==
str
?
&
tmp_value
:
str
);
if
(
res2
)
{
int
cmp
=
binary
?
stringcmp
(
res
,
res2
)
:
sortcmp
(
res
,
res2
);
int
cmp
=
binary
()
?
stringcmp
(
res
,
res2
)
:
sortcmp
(
res
,
res2
);
if
((
cmp_sign
<
0
?
cmp
:
-
cmp
)
<
0
)
res
=
res2
;
}
...
...
@@ -926,7 +923,7 @@ longlong Item_func_char_length::val_int()
return
0
;
/* purecov: inspected */
}
null_value
=
0
;
return
(
longlong
)
(
!
args
[
0
]
->
binary
)
?
res
->
numchars
()
:
res
->
length
();
return
(
longlong
)
(
!
args
[
0
]
->
binary
()
)
?
res
->
numchars
()
:
res
->
length
();
}
...
...
@@ -934,7 +931,7 @@ longlong Item_func_locate::val_int()
{
String
*
a
=
args
[
0
]
->
val_str
(
&
value1
);
String
*
b
=
args
[
1
]
->
val_str
(
&
value2
);
bool
binary_str
=
args
[
0
]
->
binary
||
args
[
1
]
->
binary
;
bool
binary_str
=
args
[
0
]
->
binary
()
||
args
[
1
]
->
binary
()
;
if
(
!
a
||
!
b
)
{
null_value
=
1
;
...
...
@@ -989,7 +986,7 @@ longlong Item_func_locate::val_int()
return
0
;
}
#endif
/* USE_MB */
return
(
longlong
)
(
binary
?
a
->
strstr
(
*
b
,
start
)
:
return
(
longlong
)
(
binary
()
?
a
->
strstr
(
*
b
,
start
)
:
(
a
->
strstr_case
(
*
b
,
start
)))
+
1
;
}
...
...
@@ -1033,7 +1030,7 @@ longlong Item_func_ord::val_int()
null_value
=
0
;
if
(
!
res
->
length
())
return
0
;
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
args
[
0
]
->
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
args
[
0
]
->
binary
()
)
{
register
const
char
*
str
=
res
->
ptr
();
register
uint32
n
=
0
,
l
=
my_ismbchar
(
res
->
charset
(),
str
,
str
+
res
->
length
());
...
...
@@ -1232,7 +1229,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func,
args
=
arguments
;
/* Fix all arguments */
func
->
binary
=
func
->
maybe_null
=
0
;
func
->
maybe_null
=
0
;
used_tables_cache
=
0
;
const_item_cache
=
1
;
...
...
@@ -1253,8 +1250,8 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func,
{
if
((
*
arg
)
->
fix_fields
(
thd
,
tables
,
arg
))
return
1
;
if
((
*
arg
)
->
binary
)
func
->
binary
=
1
;
if
((
*
arg
)
->
binary
()
)
func
->
set_charset
(
my_charset_bin
)
;
if
((
*
arg
)
->
maybe_null
)
func
->
maybe_null
=
1
;
func
->
with_sum_func
=
func
->
with_sum_func
||
(
*
arg
)
->
with_sum_func
;
...
...
sql/item_strfunc.cc
View file @
95aef915
...
...
@@ -232,6 +232,8 @@ String *Item_func_concat::val_str(String *str)
use_as_buff
=
&
tmp_value
;
for
(
i
=
1
;
i
<
arg_count
;
i
++
)
{
if
(
args
[
i
]
->
binary
())
set_charset
(
my_charset_bin
);
if
(
res
->
length
()
==
0
)
{
if
(
!
(
res
=
args
[
i
]
->
val_str
(
str
)))
...
...
@@ -260,6 +262,7 @@ String *Item_func_concat::val_str(String *str)
str
->
append
(
*
res2
);
}
res
=
str
;
res
->
set_charset
(
charset
());
}
else
if
(
res
==
&
tmp_value
)
{
...
...
@@ -271,6 +274,7 @@ String *Item_func_concat::val_str(String *str)
if
(
tmp_value
.
replace
(
0
,
0
,
*
res
))
goto
null
;
res
=
&
tmp_value
;
res
->
set_charset
(
charset
());
use_as_buff
=
str
;
// Put next arg here
}
else
if
(
tmp_value
.
is_alloced
()
&&
res2
->
ptr
()
>=
tmp_value
.
ptr
()
&&
...
...
@@ -289,6 +293,7 @@ String *Item_func_concat::val_str(String *str)
*
res
))
goto
null
;
res
=
&
tmp_value
;
res
->
set_charset
(
charset
());
use_as_buff
=
str
;
// Put next arg here
}
else
...
...
@@ -298,6 +303,7 @@ String *Item_func_concat::val_str(String *str)
tmp_value
.
append
(
*
res2
))
goto
null
;
res
=
&
tmp_value
;
res
->
set_charset
(
charset
());
use_as_buff
=
str
;
}
}
...
...
@@ -626,7 +632,7 @@ String *Item_func_reverse::val_str(String *str)
ptr
=
(
char
*
)
res
->
ptr
();
end
=
ptr
+
res
->
length
();
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
binary
()
)
{
String
tmpstr
;
tmpstr
.
copy
(
*
res
);
...
...
@@ -689,7 +695,7 @@ String *Item_func_replace::val_str(String *str)
goto
null
;
#ifdef USE_MB
binary_str
=
(
args
[
0
]
->
binary
||
args
[
1
]
->
binary
||
!
use_mb
(
res
->
charset
()));
binary_str
=
(
args
[
0
]
->
binary
()
||
args
[
1
]
->
binary
()
||
!
use_mb
(
res
->
charset
()));
#endif
if
(
res2
->
length
()
==
0
)
...
...
@@ -797,7 +803,7 @@ String *Item_func_insert::val_str(String *str)
args
[
3
]
->
null_value
)
goto
null
;
/* purecov: inspected */
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
args
[
0
]
->
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
args
[
0
]
->
binary
()
)
{
start
=
res
->
charpos
(
start
);
length
=
res
->
charpos
(
length
,
start
);
...
...
@@ -870,7 +876,7 @@ String *Item_func_left::val_str(String *str)
if
(
length
<=
0
)
return
&
empty_string
;
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
binary
()
)
length
=
res
->
charpos
(
length
);
#endif
if
(
res
->
length
()
>
(
ulong
)
length
)
...
...
@@ -878,7 +884,7 @@ String *Item_func_left::val_str(String *str)
if
(
!
res
->
alloced_length
())
{
// Don't change const str
str_value
=
*
res
;
// Not malloced string
s
tr_value
.
s
et_charset
(
res
->
charset
());
set_charset
(
res
->
charset
());
res
=
&
str_value
;
}
res
->
length
((
uint
)
length
);
...
...
@@ -919,7 +925,7 @@ String *Item_func_right::val_str(String *str)
if
(
res
->
length
()
<=
(
uint
)
length
)
return
res
;
/* purecov: inspected */
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
binary
()
)
{
uint
start
=
res
->
numchars
()
-
(
uint
)
length
;
if
(
start
<=
0
)
return
res
;
...
...
@@ -952,7 +958,7 @@ String *Item_func_substr::val_str(String *str)
(
arg_count
==
3
&&
args
[
2
]
->
null_value
))))
return
0
;
/* purecov: inspected */
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
binary
()
)
{
start
=
res
->
charpos
(
start
);
length
=
res
->
charpos
(
length
,
start
);
...
...
@@ -1012,7 +1018,7 @@ String *Item_func_substr_index::val_str(String *str)
return
&
empty_string
;
// Wrong parameters
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
binary
()
)
{
const
char
*
ptr
=
res
->
ptr
();
const
char
*
strend
=
ptr
+
res
->
length
();
...
...
@@ -1166,7 +1172,7 @@ String *Item_func_rtrim::val_str(String *str)
{
char
chr
=
(
*
remove_str
)[
0
];
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
binary
()
)
{
while
(
ptr
<
end
)
{
...
...
@@ -1183,7 +1189,7 @@ String *Item_func_rtrim::val_str(String *str)
{
const
char
*
r_ptr
=
remove_str
->
ptr
();
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
binary
()
)
{
loop:
while
(
ptr
+
remove_length
<
end
)
...
...
@@ -1234,7 +1240,7 @@ String *Item_func_trim::val_str(String *str)
while
(
ptr
+
remove_length
<=
end
&&
!
memcmp
(
ptr
,
r_ptr
,
remove_length
))
ptr
+=
remove_length
;
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
())
&&
!
binary
)
if
(
use_mb
(
res
->
charset
())
&&
!
binary
()
)
{
char
*
p
=
ptr
;
register
uint32
l
;
...
...
@@ -1965,7 +1971,7 @@ String *Item_func_conv_charset::val_str(String *str)
void
Item_func_conv_charset
::
fix_length_and_dec
()
{
max_length
=
args
[
0
]
->
max_length
*
(
conv_charset
->
mbmaxlen
?
conv_charset
->
mbmaxlen
:
1
);
s
tr_value
.
s
et_charset
(
conv_charset
);
set_charset
(
conv_charset
);
}
...
...
@@ -2040,7 +2046,6 @@ String *Item_func_conv_charset3::val_str(String *str)
bool
Item_func_conv_charset
::
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
tables
,
Item
**
ref
)
{
char
buff
[
STACK_BUFF_ALLOC
];
// Max argument in function
binary
=
0
;
used_tables_cache
=
0
;
const_item_cache
=
1
;
...
...
@@ -2049,9 +2054,8 @@ bool Item_func_conv_charset::fix_fields(THD *thd,struct st_table_list *tables, I
if
(
args
[
0
]
->
fix_fields
(
thd
,
tables
,
args
))
return
1
;
maybe_null
=
args
[
0
]
->
maybe_null
;
binary
=
args
[
0
]
->
binary
;
const_item_cache
=
args
[
0
]
->
const_item
();
s
tr_value
.
s
et_charset
(
conv_charset
);
set_charset
(
conv_charset
);
fix_length_and_dec
();
return
0
;
}
...
...
@@ -2074,7 +2078,6 @@ String *Item_func_set_collation::val_str(String *str)
bool
Item_func_set_collation
::
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
tables
,
Item
**
ref
)
{
char
buff
[
STACK_BUFF_ALLOC
];
// Max argument in function
binary
=
0
;
used_tables_cache
=
0
;
const_item_cache
=
1
;
...
...
@@ -2083,8 +2086,7 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables,
if
(
args
[
0
]
->
fix_fields
(
thd
,
tables
,
args
))
return
1
;
maybe_null
=
args
[
0
]
->
maybe_null
;
binary
=
args
[
0
]
->
binary
;
str_value
.
set_charset
(
set_collation
);
set_charset
(
set_collation
);
with_sum_func
=
with_sum_func
||
args
[
0
]
->
with_sum_func
;
used_tables_cache
=
args
[
0
]
->
used_tables
();
const_item_cache
=
args
[
0
]
->
const_item
();
...
...
sql/item_strfunc.h
View file @
95aef915
...
...
@@ -395,7 +395,7 @@ class Item_func_char :public Item_str_func
public:
Item_func_char
(
List
<
Item
>
&
list
)
:
Item_str_func
(
list
)
{}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
{
maybe_null
=
0
;
max_length
=
arg_count
;
binary
=
0
;
}
void
fix_length_and_dec
()
{
maybe_null
=
0
;
max_length
=
arg_count
;
}
const
char
*
func_name
()
const
{
return
"char"
;
}
};
...
...
@@ -467,7 +467,11 @@ class Item_func_binary :public Item_str_func
null_value
=
args
[
0
]
->
null_value
;
return
tmp
;
}
void
fix_length_and_dec
()
{
binary
=
1
;
max_length
=
args
[
0
]
->
max_length
;
}
void
fix_length_and_dec
()
{
str_value
.
set_charset
(
my_charset_bin
);
max_length
=
args
[
0
]
->
max_length
;
}
void
print
(
String
*
str
)
{
print_op
(
str
);
}
};
...
...
@@ -480,7 +484,11 @@ class Item_load_file :public Item_str_func
String
*
val_str
(
String
*
);
const
char
*
func_name
()
const
{
return
"load_file"
;
}
void
fix_length_and_dec
()
{
binary
=
1
;
maybe_null
=
1
;
max_length
=
MAX_BLOB_WIDTH
;}
{
str_value
.
set_charset
(
my_charset_bin
);
maybe_null
=
1
;
max_length
=
MAX_BLOB_WIDTH
;
}
};
...
...
sql/item_sum.cc
View file @
95aef915
...
...
@@ -160,7 +160,6 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
max_length
=
item
->
max_length
;
decimals
=
item
->
decimals
;
maybe_null
=
item
->
maybe_null
;
binary
=
item
->
binary
;
unsigned_flag
=
item
->
unsigned_flag
;
result_field
=
0
;
null_value
=
1
;
...
...
@@ -380,7 +379,7 @@ bool Item_sum_min::add()
String
*
result
=
args
[
0
]
->
val_str
(
&
tmp_value
);
if
(
!
args
[
0
]
->
null_value
&&
(
null_value
||
(
binary
?
stringcmp
(
&
value
,
result
)
:
sortcmp
(
&
value
,
result
))
>
0
))
(
binary
()
?
stringcmp
(
&
value
,
result
)
:
sortcmp
(
&
value
,
result
))
>
0
))
{
value
.
copy
(
*
result
);
null_value
=
0
;
...
...
@@ -423,7 +422,7 @@ bool Item_sum_max::add()
String
*
result
=
args
[
0
]
->
val_str
(
&
tmp_value
);
if
(
!
args
[
0
]
->
null_value
&&
(
null_value
||
(
binary
?
stringcmp
(
&
value
,
result
)
:
sortcmp
(
&
value
,
result
))
<
0
))
(
binary
()
&
MY_CS_BINSORT
?
stringcmp
(
&
value
,
result
)
:
sortcmp
(
&
value
,
result
))
<
0
))
{
value
.
copy
(
*
result
);
null_value
=
0
;
...
...
@@ -693,7 +692,7 @@ Item_sum_hybrid::min_max_update_str_field(int offset)
result_field
->
ptr
-=
offset
;
if
(
result_field
->
is_null
()
||
(
cmp_sign
*
(
binary
?
stringcmp
(
res_str
,
&
tmp_value
)
:
(
cmp_sign
*
(
binary
()
?
stringcmp
(
res_str
,
&
tmp_value
)
:
sortcmp
(
res_str
,
&
tmp_value
))
<
0
))
result_field
->
store
(
res_str
->
ptr
(),
res_str
->
length
(),
res_str
->
charset
());
else
...
...
sql/sql_analyse.cc
View file @
95aef915
...
...
@@ -349,7 +349,7 @@ void field_str::add()
if
(
length
>
max_length
)
max_length
=
length
;
if
(
item
->
binary
)
if
(
item
->
binary
()
)
{
if
(
stringcmp
(
res
,
&
min_arg
)
<
0
)
min_arg
.
copy
(
*
res
);
...
...
@@ -738,7 +738,7 @@ void field_str::get_opt_type(String *answer, ha_rows total_rows)
{
if
(
must_be_blob
)
{
if
(
item
->
binary
)
if
(
item
->
binary
()
)
answer
->
append
(
"TINYBLOB"
,
8
);
else
answer
->
append
(
"TINYTEXT"
,
8
);
...
...
@@ -756,21 +756,21 @@ void field_str::get_opt_type(String *answer, ha_rows total_rows)
}
else
if
(
max_length
<
(
1L
<<
16
))
{
if
(
item
->
binary
)
if
(
item
->
binary
()
)
answer
->
append
(
"BLOB"
,
4
);
else
answer
->
append
(
"TEXT"
,
4
);
}
else
if
(
max_length
<
(
1L
<<
24
))
{
if
(
item
->
binary
)
if
(
item
->
binary
()
)
answer
->
append
(
"MEDIUMBLOB"
,
10
);
else
answer
->
append
(
"MEDIUMTEXT"
,
10
);
}
else
{
if
(
item
->
binary
)
if
(
item
->
binary
()
)
answer
->
append
(
"LONGBLOB"
,
8
);
else
answer
->
append
(
"LONGTEXT"
,
8
);
...
...
sql/sql_analyse.h
View file @
95aef915
...
...
@@ -115,7 +115,7 @@ class field_str :public field_info
max_arg
(
""
,
default_charset_info
),
sum
(
0
),
must_be_blob
(
0
),
was_zero_fill
(
0
),
was_maybe_zerofill
(
0
),
can_be_still_num
(
1
)
{
init_tree
(
&
tree
,
0
,
0
,
sizeof
(
String
),
a
->
binary
?
{
init_tree
(
&
tree
,
0
,
0
,
sizeof
(
String
),
a
->
binary
()
?
(
qsort_cmp2
)
stringcmp2
:
(
qsort_cmp2
)
sortcmp2
,
0
,
(
tree_element_free
)
free_string
,
NULL
);
};
...
...
sql/sql_class.cc
View file @
95aef915
...
...
@@ -882,7 +882,7 @@ bool select_singleval_subselect::send_data(List<Item> &items)
{
it
->
max_length
=
val_item
->
max_length
;
it
->
decimals
=
val_item
->
decimals
;
it
->
binary
=
val_item
->
binary
;
it
->
set_charset
(
val_item
->
charset
())
;
it
->
int_value
=
val_item
->
val_int_result
();
String
*
s
=
val_item
->
str_result
(
&
it
->
string_value
);
if
(
s
!=
&
it
->
string_value
)
...
...
sql/sql_select.cc
View file @
95aef915
...
...
@@ -3600,14 +3600,14 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case
Item_sum
:
:
AVG_FUNC
:
/* Place for sum & count */
if
(
group
)
return
new
Field_string
(
sizeof
(
double
)
+
sizeof
(
longlong
),
maybe_null
,
item
->
name
,
table
,
1
,
default_charset_info
);
maybe_null
,
item
->
name
,
table
,
my_charset_bin
);
else
return
new
Field_double
(
item_sum
->
max_length
,
maybe_null
,
item
->
name
,
table
,
item_sum
->
decimals
);
case
Item_sum
:
:
STD_FUNC
:
/* Place for sum & count */
if
(
group
)
return
new
Field_string
(
sizeof
(
double
)
*
2
+
sizeof
(
longlong
),
maybe_null
,
item
->
name
,
table
,
1
,
default_charset_info
);
maybe_null
,
item
->
name
,
table
,
my_charset_bin
);
else
return
new
Field_double
(
item_sum
->
max_length
,
maybe_null
,
item
->
name
,
table
,
item_sum
->
decimals
);
...
...
@@ -3624,9 +3624,9 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case
STRING_RESULT
:
if
(
item_sum
->
max_length
>
255
)
return
new
Field_blob
(
item_sum
->
max_length
,
maybe_null
,
item
->
name
,
table
,
item
->
binary
,
default_charset_info
);
item
->
name
,
table
,
item
->
str_value
.
charset
()
);
return
new
Field_string
(
item_sum
->
max_length
,
maybe_null
,
item
->
name
,
table
,
item
->
binary
,
default_charset_info
);
item
->
name
,
table
,
item
->
str_value
.
charset
()
);
}
}
thd
->
fatal_error
=
1
;
...
...
@@ -3678,12 +3678,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case
STRING_RESULT
:
if
(
item
->
max_length
>
255
)
new_field
=
new
Field_blob
(
item
->
max_length
,
maybe_null
,
item
->
name
,
table
,
item
->
binary
,
item
->
str_value
.
charset
());
item
->
name
,
table
,
item
->
str_value
.
charset
());
else
new_field
=
new
Field_string
(
item
->
max_length
,
maybe_null
,
item
->
name
,
table
,
item
->
binary
,
item
->
str_value
.
charset
());
item
->
name
,
table
,
item
->
str_value
.
charset
());
break
;
}
if
(
copy_func
)
...
...
@@ -4121,7 +4119,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
(
uchar
*
)
0
,
(
uint
)
0
,
Field
::
NONE
,
NullS
,
table
,
(
bool
)
1
,
default_charset_info
);
NullS
,
table
,
my_charset_bin
);
key_part_info
->
key_type
=
FIELDFLAG_BINARY
;
key_part_info
->
type
=
HA_KEYTYPE_BINARY
;
key_part_info
++
;
...
...
sql/sql_select.h
View file @
95aef915
...
...
@@ -290,7 +290,7 @@ class store_key :public Sql_alloc
if
(
field_arg
->
type
()
==
FIELD_TYPE_BLOB
)
to_field
=
new
Field_varstring
(
ptr
,
length
,
(
uchar
*
)
null
,
1
,
Field
::
NONE
,
field_arg
->
field_name
,
field_arg
->
table
,
field_arg
->
binary
(),
default_charset_info
);
field_arg
->
table
,
field_arg
->
charset
()
);
else
{
to_field
=
field_arg
->
new_field
(
&
thd
->
mem_root
,
field_arg
->
table
);
...
...
sql/sql_string.cc
View file @
95aef915
...
...
@@ -521,12 +521,23 @@ int sortcmp(const String *x,const String *y)
#endif
/* USE_STRCOLL */
x_len
-=
len
;
// For easy end space test
y_len
-=
len
;
while
(
len
--
)
if
(
x
->
str_charset
->
sort_order
)
{
if
(
x
->
str_charset
->
sort_order
[(
uchar
)
*
s
++
]
!=
while
(
len
--
)
{
if
(
x
->
str_charset
->
sort_order
[(
uchar
)
*
s
++
]
!=
x
->
str_charset
->
sort_order
[(
uchar
)
*
t
++
])
return
((
int
)
x
->
str_charset
->
sort_order
[(
uchar
)
s
[
-
1
]]
-
(
int
)
x
->
str_charset
->
sort_order
[(
uchar
)
t
[
-
1
]]);
return
((
int
)
x
->
str_charset
->
sort_order
[(
uchar
)
s
[
-
1
]]
-
(
int
)
x
->
str_charset
->
sort_order
[(
uchar
)
t
[
-
1
]]);
}
}
else
{
while
(
len
--
)
{
if
(
*
s
++
!=
*
t
++
)
return
((
int
)
s
[
-
1
]
-
(
int
)
t
[
-
1
]);
}
}
#ifndef CMP_ENDSPACE
/* Don't compare end space in strings */
...
...
sql/sql_table.cc
View file @
95aef915
...
...
@@ -383,6 +383,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
it
.
rewind
();
while
((
sql_field
=
it
++
))
{
if
(
!
sql_field
->
charset
)
sql_field
->
charset
=
create_info
->
table_charset
?
create_info
->
table_charset
:
thd
->
db_charset
?
thd
->
db_charset
:
default_charset_info
;
switch
(
sql_field
->
sql_type
)
{
case
FIELD_TYPE_BLOB
:
case
FIELD_TYPE_MEDIUM_BLOB
:
...
...
@@ -391,7 +397,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
sql_field
->
pack_flag
=
FIELDFLAG_BLOB
|
pack_length_to_packflag
(
sql_field
->
pack_length
-
portable_sizeof_char_ptr
);
if
(
sql_field
->
flags
&
BINARY_FLAG
)
if
(
sql_field
->
charset
->
state
&
MY_CS_BINSORT
)
sql_field
->
pack_flag
|=
FIELDFLAG_BINARY
;
sql_field
->
length
=
8
;
// Unireg field length
sql_field
->
unireg_check
=
Field
::
BLOB_FIELD
;
...
...
@@ -400,7 +406,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
case
FIELD_TYPE_VAR_STRING
:
case
FIELD_TYPE_STRING
:
sql_field
->
pack_flag
=
0
;
if
(
sql_field
->
flags
&
BINARY_FLAG
)
if
(
sql_field
->
charset
->
state
&
MY_CS_BINSORT
)
sql_field
->
pack_flag
|=
FIELDFLAG_BINARY
;
break
;
case
FIELD_TYPE_ENUM
:
...
...
@@ -438,11 +444,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
sql_field
->
offset
=
pos
;
if
(
MTYP_TYPENR
(
sql_field
->
unireg_check
)
==
Field
::
NEXT_NUMBER
)
auto_increment
++
;
if
(
!
sql_field
->
charset
)
sql_field
->
charset
=
create_info
->
table_charset
?
create_info
->
table_charset
:
thd
->
db_charset
?
thd
->
db_charset
:
default_charset_info
;
pos
+=
sql_field
->
pack_length
;
}
if
(
auto_increment
>
1
)
...
...
sql/sql_update.cc
View file @
95aef915
...
...
@@ -482,8 +482,7 @@ multi_update::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if
(
counter
)
{
Field_string
offset
(
table_ref
->
table
->
file
->
ref_length
,
false
,
"offset"
,
table_ref
->
table
,
true
,
default_charset_info
);
"offset"
,
table_ref
->
table
,
my_charset_bin
);
temp_fields
->
push_front
(
new
Item_field
(((
Field
*
)
&
offset
)));
// Make a temporary table
...
...
sql/sql_yacc.yy
View file @
95aef915
...
...
@@ -1029,12 +1029,12 @@ type:
| char opt_binary { Lex->length=(char*) "1";
$$=FIELD_TYPE_STRING; }
| BINARY '(' NUM ')' { Lex->length=$3.str;
Lex->
type|=BINARY_FLAG
;
Lex->
charset=my_charset_bin
;
$$=FIELD_TYPE_STRING; }
| varchar '(' NUM ')' opt_binary { Lex->length=$3.str;
$$=FIELD_TYPE_VAR_STRING; }
| VARBINARY '(' NUM ')' { Lex->length=$3.str;
Lex->
type|=BINARY_FLAG
;
Lex->
charset=my_charset_bin
;
$$=FIELD_TYPE_VAR_STRING; }
| YEAR_SYM opt_len field_options { $$=FIELD_TYPE_YEAR; Lex->length=$2; }
| DATE_SYM { $$=FIELD_TYPE_DATE; }
...
...
@@ -1043,17 +1043,17 @@ type:
| TIMESTAMP '(' NUM ')' { Lex->length=$3.str;
$$=FIELD_TYPE_TIMESTAMP; }
| DATETIME { $$=FIELD_TYPE_DATETIME; }
| TINYBLOB { Lex->
type|=BINARY_FLAG
;
| TINYBLOB { Lex->
charset=my_charset_bin
;
$$=FIELD_TYPE_TINY_BLOB; }
| BLOB_SYM { Lex->
type|=BINARY_FLAG
;
| BLOB_SYM { Lex->
charset=my_charset_bin
;
$$=FIELD_TYPE_BLOB; }
| GEOMETRY_SYM { Lex->
type|=BINARY_FLAG
;
| GEOMETRY_SYM { Lex->
charset=my_charset_bin
;
$$=FIELD_TYPE_GEOMETRY; }
| MEDIUMBLOB { Lex->
type|=BINARY_FLAG
;
| MEDIUMBLOB { Lex->
charset=my_charset_bin
;
$$=FIELD_TYPE_MEDIUM_BLOB; }
| LONGBLOB { Lex->
type|=BINARY_FLAG
;
| LONGBLOB { Lex->
charset=my_charset_bin
;
$$=FIELD_TYPE_LONG_BLOB; }
| LONG_SYM VARBINARY { Lex->
type|=BINARY_FLAG
;
| LONG_SYM VARBINARY { Lex->
charset=my_charset_bin
;
$$=FIELD_TYPE_MEDIUM_BLOB; }
| LONG_SYM varchar opt_binary { $$=FIELD_TYPE_MEDIUM_BLOB; }
| TINYTEXT opt_binary { $$=FIELD_TYPE_TINY_BLOB; }
...
...
@@ -1186,7 +1186,7 @@ opt_db_default_character_set:
opt_binary:
/* empty */ { Lex->charset=NULL; }
| BINARY { Lex->
type|=BINARY_FLAG; Lex->charset=NULL
; }
| BINARY { Lex->
charset=my_charset_bin
; }
| CHAR_SYM SET charset_name { Lex->charset=$3; } ;
references:
...
...
@@ -1849,7 +1849,7 @@ simple_expr:
| MATCH ident_list_arg AGAINST '(' expr IN_SYM BOOLEAN_SYM MODE_SYM ')'
{ Select->ftfunc_list->push_back((Item_func_match *)
($$=new Item_func_match_bool(*$2,$5))); }
| BINARY expr %prec NEG
{ $$= new Item_func_binary($2
); }
| BINARY expr %prec NEG
{ $$= new Item_func_set_collation($2,my_charset_bin
); }
| CAST_SYM '(' expr AS cast_type ')' { $$= create_func_cast($3, $5); }
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
{ $$= new Item_func_case(* $4, $2, $5 ); }
...
...
@@ -3291,7 +3291,7 @@ text_string:
TEXT_STRING { $$= new String($1.str,$1.length,default_charset_info); }
| HEX_NUM
{
Item *tmp = new Item_varbinary($1.str,$1.length
,default_charset_info
);
Item *tmp = new Item_varbinary($1.str,$1.length);
$$= tmp ? tmp->val_str((String*) 0) : (String*) 0;
};
param_marker:
...
...
@@ -3318,7 +3318,7 @@ literal:
| FLOAT_NUM { $$ = new Item_float($1.str, $1.length); }
| NULL_SYM { $$ = new Item_null();
Lex->next_state=STATE_OPERATOR_OR_IDENT;}
| HEX_NUM { $$ = new Item_varbinary($1.str,$1.length
,default_charset_info
);}
| HEX_NUM { $$ = new Item_varbinary($1.str,$1.length);}
| DATE_SYM text_literal { $$ = $2; }
| TIME_SYM text_literal { $$ = $2; }
| TIMESTAMP text_literal { $$ = $2; };
...
...
sql/table.cc
View file @
95aef915
...
...
@@ -349,7 +349,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
uint
pack_flag
=
uint2korr
(
strpos
+
6
);
uint
interval_nr
=
(
uint
)
strpos
[
10
];
enum_field_types
field_type
;
CHARSET_INFO
*
charset
;
CHARSET_INFO
*
charset
=
NULL
;
LEX_STRING
comment
;
if
(
new_frm_ver
==
2
)
...
...
@@ -384,6 +384,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
null_pos
,
null_bit
,
pack_flag
,
field_type
,
charset
,
(
Field
::
utype
)
MTYP_TYPENR
((
uint
)
strpos
[
8
]),
(
interval_nr
?
outparam
->
intervals
+
interval_nr
-
1
:
...
...
sql/unireg.cc
View file @
95aef915
...
...
@@ -572,6 +572,7 @@ static bool make_empty_rec(File file,enum db_type table_type,
1
<<
(
null_count
&
7
),
field
->
pack_flag
,
field
->
sql_type
,
field
->
charset
,
field
->
unireg_check
,
field
->
interval
,
field
->
field_name
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment