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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
5d4fbc02
Commit
5d4fbc02
authored
May 23, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatic conversion into supersets (utf8, ucs2) for comparison in some cases
USER(), DATABASE() and VERSION() return in utf8 now
parent
46c730e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
7 deletions
+65
-7
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+56
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+5
-3
sql/item_strfunc.h
sql/item_strfunc.h
+4
-4
No files found.
sql/item_cmpfunc.cc
View file @
5d4fbc02
...
@@ -133,6 +133,60 @@ bool Item_bool_func2::fix_fields(THD *thd, struct st_table_list *tables,
...
@@ -133,6 +133,60 @@ bool Item_bool_func2::fix_fields(THD *thd, struct st_table_list *tables,
{
{
if
(
Item_int_func
::
fix_fields
(
thd
,
tables
,
ref
))
if
(
Item_int_func
::
fix_fields
(
thd
,
tables
,
ref
))
return
1
;
return
1
;
/*
We allow to convert to Unicode character sets in some cases.
The conditions when conversion is possible are:
- arguments A and B have different charsets
- A wins according to coercibility rules
- character set of A is superset for character set of B
If all of the above is true, then it's possible to convert
B into the character set of A, and then compare according
to the collation of A.
*/
if
(
args
[
0
]
&&
args
[
1
])
{
uint
strong
=
0
;
uint
weak
=
0
;
if
((
args
[
0
]
->
coercibility
<
args
[
1
]
->
coercibility
)
&&
!
my_charset_same
(
args
[
0
]
->
charset
(),
args
[
1
]
->
charset
())
&&
(
args
[
0
]
->
charset
()
->
state
&
MY_CS_UNICODE
))
{
weak
=
1
;
}
else
if
((
args
[
1
]
->
coercibility
<
args
[
0
]
->
coercibility
)
&&
!
my_charset_same
(
args
[
0
]
->
charset
(),
args
[
1
]
->
charset
())
&&
(
args
[
1
]
->
charset
()
->
state
&
MY_CS_UNICODE
))
{
strong
=
1
;
}
if
(
strong
||
weak
)
{
Item
*
conv
=
0
;
if
(
args
[
weak
]
->
type
()
==
STRING_ITEM
)
{
String
tmp
,
cstr
;
String
*
ostr
=
args
[
weak
]
->
val_str
(
&
tmp
);
cstr
.
copy
(
ostr
->
ptr
(),
ostr
->
length
(),
ostr
->
charset
(),
args
[
strong
]
->
charset
());
conv
=
new
Item_string
(
cstr
.
ptr
(),
cstr
.
length
(),
cstr
.
charset
(),
args
[
weak
]
->
coercibility
);
((
Item_string
*
)
conv
)
->
str_value
.
copy
();
}
else
{
conv
=
new
Item_func_conv_charset
(
args
[
weak
],
args
[
strong
]
->
charset
());
conv
->
coercibility
=
args
[
weak
]
->
coercibility
;
}
args
[
weak
]
=
conv
?
conv
:
args
[
weak
];
set_cmp_charset
(
args
[
0
]
->
charset
(),
args
[
0
]
->
coercibility
,
args
[
1
]
->
charset
(),
args
[
1
]
->
coercibility
);
}
}
if
(
!
cmp_charset
)
if
(
!
cmp_charset
)
{
{
/* set_cmp_charset() failed */
/* set_cmp_charset() failed */
...
@@ -156,6 +210,8 @@ void Item_bool_func2::fix_length_and_dec()
...
@@ -156,6 +210,8 @@ void Item_bool_func2::fix_length_and_dec()
*/
*/
if
(
!
args
[
0
]
||
!
args
[
1
])
if
(
!
args
[
0
]
||
!
args
[
1
])
return
;
return
;
// Make a special case of compare with fields to get nicer DATE comparisons
// Make a special case of compare with fields to get nicer DATE comparisons
if
(
args
[
0
]
->
type
()
==
FIELD_ITEM
)
if
(
args
[
0
]
->
type
()
==
FIELD_ITEM
)
{
{
...
...
sql/item_strfunc.cc
View file @
5d4fbc02
...
@@ -1459,10 +1459,12 @@ String *Item_func_database::val_str(String *str)
...
@@ -1459,10 +1459,12 @@ String *Item_func_database::val_str(String *str)
{
{
THD
*
thd
=
current_thd
;
THD
*
thd
=
current_thd
;
if
(
!
thd
->
db
)
if
(
!
thd
->
db
)
{
str
->
length
(
0
);
str
->
length
(
0
);
str
->
set_charset
(
system_charset_info
);
}
else
else
str
->
copy
((
const
char
*
)
thd
->
db
,(
uint
)
strlen
(
thd
->
db
),
str
->
copy
((
const
char
*
)
thd
->
db
,(
uint
)
strlen
(
thd
->
db
),
system_charset_info
);
system_charset_info
,
default_charset
());
return
str
;
return
str
;
}
}
...
@@ -1471,7 +1473,7 @@ String *Item_func_database::val_str(String *str)
...
@@ -1471,7 +1473,7 @@ String *Item_func_database::val_str(String *str)
String
*
Item_func_user
::
val_str
(
String
*
str
)
String
*
Item_func_user
::
val_str
(
String
*
str
)
{
{
THD
*
thd
=
current_thd
;
THD
*
thd
=
current_thd
;
CHARSET_INFO
*
cs
=
default_charset
()
;
CHARSET_INFO
*
cs
=
system_charset_info
;
const
char
*
host
=
thd
->
host_or_ip
;
const
char
*
host
=
thd
->
host_or_ip
;
uint
res_length
;
uint
res_length
;
...
...
sql/item_strfunc.h
View file @
5d4fbc02
...
@@ -337,8 +337,8 @@ public:
...
@@ -337,8 +337,8 @@ public:
String
*
val_str
(
String
*
);
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
void
fix_length_and_dec
()
{
{
max_length
=
MAX_FIELD_NAME
*
default_charset
()
->
mbmaxlen
;
max_length
=
MAX_FIELD_NAME
*
system_charset_info
->
mbmaxlen
;
set_charset
(
default_charset
()
);
set_charset
(
system_charset_info
);
}
}
const
char
*
func_name
()
const
{
return
"database"
;
}
const
char
*
func_name
()
const
{
return
"database"
;
}
};
};
...
@@ -350,8 +350,8 @@ public:
...
@@ -350,8 +350,8 @@ public:
String
*
val_str
(
String
*
);
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
void
fix_length_and_dec
()
{
{
max_length
=
(
USERNAME_LENGTH
+
HOSTNAME_LENGTH
+
1
)
*
default_charset
()
->
mbmaxlen
;
max_length
=
(
USERNAME_LENGTH
+
HOSTNAME_LENGTH
+
1
)
*
system_charset_info
->
mbmaxlen
;
set_charset
(
default_charset
()
);
set_charset
(
system_charset_info
);
}
}
const
char
*
func_name
()
const
{
return
"user"
;
}
const
char
*
func_name
()
const
{
return
"user"
;
}
};
};
...
...
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