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
d8cf7e01
Commit
d8cf7e01
authored
19 years ago
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug#9509 Optimizer: wrong result after AND with latin1_german2_ci
We cannot propagate constants with tricky collations.
parent
b6317e3a
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
115 additions
and
17 deletions
+115
-17
include/m_ctype.h
include/m_ctype.h
+5
-0
mysql-test/r/ctype_latin1_de.result
mysql-test/r/ctype_latin1_de.result
+6
-0
mysql-test/t/ctype_latin1_de.test
mysql-test/t/ctype_latin1_de.test
+8
-0
sql/sql_select.cc
sql/sql_select.cc
+7
-4
strings/ctype-big5.c
strings/ctype-big5.c
+2
-1
strings/ctype-bin.c
strings/ctype-bin.c
+4
-2
strings/ctype-cp932.c
strings/ctype-cp932.c
+1
-0
strings/ctype-czech.c
strings/ctype-czech.c
+1
-0
strings/ctype-euc_kr.c
strings/ctype-euc_kr.c
+1
-0
strings/ctype-eucjpms.c
strings/ctype-eucjpms.c
+1
-0
strings/ctype-gb2312.c
strings/ctype-gb2312.c
+1
-0
strings/ctype-gbk.c
strings/ctype-gbk.c
+1
-0
strings/ctype-latin1.c
strings/ctype-latin1.c
+2
-1
strings/ctype-mb.c
strings/ctype-mb.c
+2
-1
strings/ctype-simple.c
strings/ctype-simple.c
+56
-1
strings/ctype-sjis.c
strings/ctype-sjis.c
+1
-0
strings/ctype-tis620.c
strings/ctype-tis620.c
+1
-0
strings/ctype-uca.c
strings/ctype-uca.c
+4
-2
strings/ctype-ucs2.c
strings/ctype-ucs2.c
+4
-2
strings/ctype-ujis.c
strings/ctype-ujis.c
+1
-0
strings/ctype-utf8.c
strings/ctype-utf8.c
+4
-2
strings/ctype-win1250ch.c
strings/ctype-win1250ch.c
+2
-1
No files found.
include/m_ctype.h
View file @
d8cf7e01
...
...
@@ -132,6 +132,7 @@ typedef struct my_collation_handler_st
/* Hash calculation */
void
(
*
hash_sort
)(
struct
charset_info_st
*
cs
,
const
uchar
*
key
,
uint
len
,
ulong
*
nr1
,
ulong
*
nr2
);
my_bool
(
*
propagate
)(
struct
charset_info_st
*
cs
,
const
uchar
*
str
,
uint
len
);
}
MY_COLLATION_HANDLER
;
extern
MY_COLLATION_HANDLER
my_collation_mb_bin_handler
;
...
...
@@ -385,6 +386,10 @@ int my_wildcmp_unicode(CHARSET_INFO *cs,
extern
my_bool
my_parse_charset_xml
(
const
char
*
bug
,
uint
len
,
int
(
*
add
)(
CHARSET_INFO
*
cs
));
my_bool
my_propagate_simple
(
CHARSET_INFO
*
cs
,
const
uchar
*
str
,
uint
len
);
my_bool
my_propagate_complex
(
CHARSET_INFO
*
cs
,
const
uchar
*
str
,
uint
len
);
#define _MY_U 01
/* Upper case */
#define _MY_L 02
/* Lower case */
#define _MY_NMR 04
/* Numeral (digit) */
...
...
This diff is collapsed.
Click to expand it.
mysql-test/r/ctype_latin1_de.result
View file @
d8cf7e01
...
...
@@ -338,3 +338,9 @@ ss
ss
DROP TABLE t1;
create table t1 (s1 char(5) character set latin1 collate latin1_german2_ci);
insert into t1 values (0xf6) /* this is o-umlaut */;
select * from t1 where length(s1)=1 and s1='oe';
s1
drop table t1;
This diff is collapsed.
Click to expand it.
mysql-test/t/ctype_latin1_de.test
View file @
d8cf7e01
...
...
@@ -132,3 +132,11 @@ INSERT INTO t1 VALUES ('
ALTER
TABLE
t1
ADD
KEY
ifword
(
col1
);
SELECT
*
FROM
t1
WHERE
col1
=
''
ORDER
BY
col1
,
BINARY
col1
;
DROP
TABLE
t1
;
#
# Bug#9509
#
create
table
t1
(
s1
char
(
5
)
character
set
latin1
collate
latin1_german2_ci
);
insert
into
t1
values
(
0xf6
)
/* this is o-umlaut */
;
select
*
from
t1
where
length
(
s1
)
=
1
and
s1
=
'oe'
;
drop
table
t1
;
This diff is collapsed.
Click to expand it.
sql/sql_select.cc
View file @
d8cf7e01
...
...
@@ -6435,10 +6435,13 @@ static bool check_equality(Item *item, COND_EQUAL *cond_equal)
{
bool
copyfl
;
if
(
field_item
->
result_type
()
==
STRING_RESULT
&&
((
Field_str
*
)
field_item
->
field
)
->
charset
()
!=
((
Item_cond
*
)
item
)
->
compare_collation
())
return
FALSE
;
if
(
field_item
->
result_type
()
==
STRING_RESULT
)
{
CHARSET_INFO
*
cs
=
((
Field_str
*
)
field_item
->
field
)
->
charset
();
if
((
cs
!=
((
Item_cond
*
)
item
)
->
compare_collation
())
||
!
cs
->
coll
->
propagate
(
cs
,
0
,
0
))
return
FALSE
;
}
Item_equal
*
item_equal
=
find_item_equal
(
cond_equal
,
field_item
->
field
,
&
copyfl
);
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-big5.c
View file @
d8cf7e01
...
...
@@ -6335,7 +6335,8 @@ static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler =
my_wildcmp_mb
,
my_strcasecmp_mb
,
my_instr_mb
,
my_hash_sort_simple
my_hash_sort_simple
,
my_propagate_simple
};
static
MY_CHARSET_HANDLER
my_charset_big5_handler
=
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-bin.c
View file @
d8cf7e01
...
...
@@ -459,7 +459,8 @@ MY_COLLATION_HANDLER my_collation_8bit_bin_handler =
my_wildcmp_bin
,
my_strcasecmp_bin
,
my_instr_bin
,
my_hash_sort_bin
my_hash_sort_bin
,
my_propagate_simple
};
...
...
@@ -474,7 +475,8 @@ static MY_COLLATION_HANDLER my_collation_binary_handler =
my_wildcmp_bin
,
my_strcasecmp_bin
,
my_instr_bin
,
my_hash_sort_bin
my_hash_sort_bin
,
my_propagate_simple
};
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-cp932.c
View file @
d8cf7e01
...
...
@@ -5462,6 +5462,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_strcasecmp_8bit
,
my_instr_mb
,
my_hash_sort_simple
,
my_propagate_simple
};
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-czech.c
View file @
d8cf7e01
...
...
@@ -599,6 +599,7 @@ static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler =
my_strcasecmp_8bit
,
my_instr_simple
,
my_hash_sort_simple
,
my_propagate_simple
};
CHARSET_INFO
my_charset_latin2_czech_ci
=
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-euc_kr.c
View file @
d8cf7e01
...
...
@@ -8647,6 +8647,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_strcasecmp_mb
,
my_instr_mb
,
my_hash_sort_simple
,
my_propagate_simple
};
static
MY_CHARSET_HANDLER
my_charset_handler
=
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-eucjpms.c
View file @
d8cf7e01
...
...
@@ -8648,6 +8648,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_strcasecmp_mb
,
my_instr_mb
,
my_hash_sort_simple
,
my_propagate_simple
};
static
MY_CHARSET_HANDLER
my_charset_handler
=
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-gb2312.c
View file @
d8cf7e01
...
...
@@ -5698,6 +5698,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_strcasecmp_mb
,
/* instr */
my_instr_mb
,
my_hash_sort_simple
,
my_propagate_simple
};
static
MY_CHARSET_HANDLER
my_charset_handler
=
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-gbk.c
View file @
d8cf7e01
...
...
@@ -9945,6 +9945,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_strcasecmp_mb
,
my_instr_mb
,
my_hash_sort_simple
,
my_propagate_simple
};
static
MY_CHARSET_HANDLER
my_charset_handler
=
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-latin1.c
View file @
d8cf7e01
...
...
@@ -698,7 +698,8 @@ static MY_COLLATION_HANDLER my_collation_german2_ci_handler=
my_wildcmp_8bit
,
my_strcasecmp_8bit
,
my_instr_simple
,
my_hash_sort_latin1_de
my_hash_sort_latin1_de
,
my_propagate_complex
};
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-mb.c
View file @
d8cf7e01
...
...
@@ -920,7 +920,8 @@ MY_COLLATION_HANDLER my_collation_mb_bin_handler =
my_wildcmp_mb_bin
,
my_strcasecmp_mb_bin
,
my_instr_mb
,
my_hash_sort_mb_bin
my_hash_sort_mb_bin
,
my_propagate_simple
};
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-simple.c
View file @
d8cf7e01
...
...
@@ -1340,6 +1340,60 @@ longlong my_strtoll10_8bit(CHARSET_INFO *cs __attribute__((unused)),
}
/*
Check if a constant can be propagated
SYNOPSIS:
my_propagate_simple()
cs Character set information
str String to convert to double
length Optional length for string.
NOTES:
Takes the string in the given charset and check
if it can be safely propagated in the optimizer.
create table t1 (
s char(5) character set latin1 collate latin1_german2_ci);
insert into t1 values (0xf6); -- o-umlaut
select * from t1 where length(s)=1 and s='oe';
The above query should return one row.
We cannot convert this query into:
select * from t1 where length('oe')=1 and s='oe';
Currently we don't check the constant itself,
and decide not to propagate a constant
just if the collation itself allows tricky things
like expansions and contractions. In the future
we can write a more sophisticated functions to
check the constants. For example, 'oa' can always
be safety propagated in German2 because unlike
'oe' it does not have any special meaning.
RETURN
1 if constant can be safely propagated
0 if it is not safe to propagate the constant
*/
my_bool
my_propagate_simple
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
const
uchar
*
str
__attribute__
((
unused
)),
uint
length
__attribute__
((
unused
)))
{
return
1
;
}
my_bool
my_propagate_complex
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
const
uchar
*
str
__attribute__
((
unused
)),
uint
length
__attribute__
((
unused
)))
{
return
0
;
}
MY_CHARSET_HANDLER
my_charset_8bit_handler
=
{
my_cset_init_8bit
,
...
...
@@ -1380,5 +1434,6 @@ MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler =
my_wildcmp_8bit
,
my_strcasecmp_8bit
,
my_instr_simple
,
my_hash_sort_simple
my_hash_sort_simple
,
my_propagate_simple
};
This diff is collapsed.
Click to expand it.
strings/ctype-sjis.c
View file @
d8cf7e01
...
...
@@ -4631,6 +4631,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_strcasecmp_8bit
,
my_instr_mb
,
my_hash_sort_simple
,
my_propagate_simple
};
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-tis620.c
View file @
d8cf7e01
...
...
@@ -933,6 +933,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_strcasecmp_8bit
,
my_instr_simple
,
/* QQ: To be fixed */
my_hash_sort_simple
,
my_propagate_simple
};
static
MY_CHARSET_HANDLER
my_charset_handler
=
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-uca.c
View file @
d8cf7e01
...
...
@@ -8029,7 +8029,8 @@ MY_COLLATION_HANDLER my_collation_ucs2_uca_handler =
my_wildcmp_uca
,
NULL
,
my_instr_mb
,
my_hash_sort_ucs2_uca
my_hash_sort_ucs2_uca
,
my_propagate_complex
};
CHARSET_INFO
my_charset_ucs2_general_uca
=
...
...
@@ -8510,7 +8511,8 @@ MY_COLLATION_HANDLER my_collation_any_uca_handler =
my_wildcmp_uca
,
NULL
,
my_instr_mb
,
my_hash_sort_any_uca
my_hash_sort_any_uca
,
my_propagate_complex
};
/*
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-ucs2.c
View file @
d8cf7e01
...
...
@@ -1527,7 +1527,8 @@ static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler =
my_wildcmp_ucs2_ci
,
my_strcasecmp_ucs2
,
my_instr_mb
,
my_hash_sort_ucs2
my_hash_sort_ucs2
,
my_propagate_simple
};
...
...
@@ -1542,7 +1543,8 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler =
my_wildcmp_ucs2_bin
,
my_strcasecmp_ucs2_bin
,
my_instr_mb
,
my_hash_sort_ucs2_bin
my_hash_sort_ucs2_bin
,
my_propagate_simple
};
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-ujis.c
View file @
d8cf7e01
...
...
@@ -8516,6 +8516,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_strcasecmp_mb
,
my_instr_mb
,
my_hash_sort_simple
,
my_propagate_simple
};
static
MY_CHARSET_HANDLER
my_charset_handler
=
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-utf8.c
View file @
d8cf7e01
...
...
@@ -2316,7 +2316,8 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_wildcmp_utf8
,
my_strcasecmp_utf8
,
my_instr_mb
,
my_hash_sort_utf8
my_hash_sort_utf8
,
my_propagate_complex
};
MY_CHARSET_HANDLER
my_charset_utf8_handler
=
...
...
@@ -2540,7 +2541,8 @@ static MY_COLLATION_HANDLER my_collation_cs_handler =
my_wildcmp_mb
,
my_strcasecmp_utf8
,
my_instr_mb
,
my_hash_sort_utf8
my_hash_sort_utf8
,
my_propagate_simple
};
CHARSET_INFO
my_charset_utf8_general_cs
=
...
...
This diff is collapsed.
Click to expand it.
strings/ctype-win1250ch.c
View file @
d8cf7e01
...
...
@@ -631,7 +631,8 @@ static MY_COLLATION_HANDLER my_collation_czech_ci_handler =
my_wildcmp_8bit
,
my_strcasecmp_8bit
,
my_instr_simple
,
my_hash_sort_simple
my_hash_sort_simple
,
my_propagate_simple
};
...
...
This diff is collapsed.
Click to expand it.
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