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
04c43fca
Commit
04c43fca
authored
Sep 12, 2003
by
monty@mashka.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize thai character handling
Remove sel000xxxx tests After merge fixes
parent
7538242e
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
223 additions
and
223 deletions
+223
-223
mysql-test/r/distinct.result
mysql-test/r/distinct.result
+37
-0
mysql-test/r/grant.result
mysql-test/r/grant.result
+1
-1
mysql-test/r/range.result
mysql-test/r/range.result
+19
-6
mysql-test/r/sel000033.result
mysql-test/r/sel000033.result
+0
-14
mysql-test/r/sel000100.result
mysql-test/r/sel000100.result
+0
-38
mysql-test/t/distinct.test
mysql-test/t/distinct.test
+47
-0
mysql-test/t/range.test
mysql-test/t/range.test
+8
-0
mysql-test/t/sel000033.test
mysql-test/t/sel000033.test
+0
-20
mysql-test/t/sel000100.test
mysql-test/t/sel000100.test
+0
-48
sql/log_event.cc
sql/log_event.cc
+0
-2
sql/sql_select.cc
sql/sql_select.cc
+9
-6
strings/ctype-tis620.c
strings/ctype-tis620.c
+102
-88
No files found.
mysql-test/r/distinct.result
View file @
04c43fca
...
@@ -427,3 +427,40 @@ name
...
@@ -427,3 +427,40 @@ name
a
a
e
e
drop table t1;
drop table t1;
CREATE TABLE t1 (
ID int(11) NOT NULL auto_increment,
NAME varchar(75) DEFAULT '' NOT NULL,
LINK_ID int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (ID),
KEY NAME (NAME),
KEY LINK_ID (LINK_ID)
);
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0);
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0);
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0);
CREATE TABLE t2 (
ID int(11) NOT NULL auto_increment,
NAME varchar(150) DEFAULT '' NOT NULL,
PRIMARY KEY (ID),
KEY NAME (NAME)
);
SELECT DISTINCT
t2.id AS key_link_id,
t2.name AS link
FROM t1
LEFT JOIN t2 ON t1.link_id=t2.id
GROUP BY t1.id
ORDER BY link;
key_link_id link
NULL NULL
drop table t1,t2;
CREATE TABLE t1 (
html varchar(5) default NULL,
rin int(11) default '0',
out int(11) default '0'
) TYPE=MyISAM;
INSERT INTO t1 VALUES ('1',1,0);
SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
html prod
1 0.00
drop table t1;
mysql-test/r/grant.result
View file @
04c43fca
...
@@ -145,7 +145,7 @@ show grants for drop_user@localhost;
...
@@ -145,7 +145,7 @@ show grants for drop_user@localhost;
Grants for drop_user@localhost
Grants for drop_user@localhost
GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION
GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION
GRANT ALL PRIVILEGES ON `test`.* TO 'drop_user'@'localhost' WITH GRANT OPTION
GRANT ALL PRIVILEGES ON `test`.* TO 'drop_user'@'localhost' WITH GRANT OPTION
GRANT
USAGE
ON `test`.`t1` TO 'drop_user'@'localhost'
GRANT
SELECT (a)
ON `test`.`t1` TO 'drop_user'@'localhost'
revoke all privileges, grant from drop_user@localhost;
revoke all privileges, grant from drop_user@localhost;
show grants for drop_user@localhost;
show grants for drop_user@localhost;
Grants for drop_user@localhost
Grants for drop_user@localhost
...
...
mysql-test/r/range.result
View file @
04c43fca
...
@@ -265,11 +265,24 @@ INSERT INTO t1 VALUES (0),(0),(1),(1);
...
@@ -265,11 +265,24 @@ INSERT INTO t1 VALUES (0),(0),(1),(1);
CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya));
CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya));
INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
table type possible_keys key key_len ref rows Extra
id select_type
table type possible_keys key key_len ref rows Extra
t2 ref j1 j1 4 const 1 Using where; Using index
1 SIMPLE
t2 ref j1 j1 4 const 1 Using where; Using index
t1 ALL i1,i2 NULL NULL NULL 4 Range checked for each record (index map: 3)
1 SIMPLE
t1 ALL i1,i2 NULL NULL NULL 4 Range checked for each record (index map: 3)
explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
table type possible_keys key key_len ref rows Extra
id select_type
table type possible_keys key key_len ref rows Extra
t2 ref j1 j1 4 const 1 Using where; Using index
1 SIMPLE
t2 ref j1 j1 4 const 1 Using where; Using index
t1 ALL i2 NULL NULL NULL 4 Range checked for each record (index map: 2)
1 SIMPLE
t1 ALL i2 NULL NULL NULL 4 Range checked for each record (index map: 2)
DROP TABLE t1,t2;
DROP TABLE t1,t2;
create table t1 (id int(10) primary key);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
select id from t1 where id in (2,5,9) ;
id
2
5
9
select id from t1 where id=2 or id=5 or id=9 ;
id
2
5
9
drop table t1;
mysql-test/r/sel000033.result
deleted
100644 → 0
View file @
7538242e
drop table if exists t1;
create table t1 (id int(10) primary key);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
select id from t1 where id in (2,5,9) ;
id
2
5
9
select id from t1 where id=2 or id=5 or id=9 ;
id
2
5
9
drop table t1;
mysql-test/r/sel000100.result
deleted
100644 → 0
View file @
7538242e
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
ID int(11) NOT NULL auto_increment,
NAME varchar(75) DEFAULT '' NOT NULL,
LINK_ID int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (ID),
KEY NAME (NAME),
KEY LINK_ID (LINK_ID)
);
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0);
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0);
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0);
CREATE TABLE t2 (
ID int(11) NOT NULL auto_increment,
NAME varchar(150) DEFAULT '' NOT NULL,
PRIMARY KEY (ID),
KEY NAME (NAME)
);
SELECT DISTINCT
t2.id AS key_link_id,
t2.name AS link
FROM t1
LEFT JOIN t2 ON t1.link_id=t2.id
GROUP BY t1.id
ORDER BY link;
key_link_id link
NULL NULL
drop table t1,t2;
CREATE TABLE t1 (
html varchar(5) default NULL,
rin int(11) default '0',
out int(11) default '0'
) TYPE=MyISAM;
INSERT INTO t1 VALUES ('1',1,0);
SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
html prod
1 0.00
drop table t1;
mysql-test/t/distinct.test
View file @
04c43fca
...
@@ -285,3 +285,50 @@ INSERT INTO t1 VALUES (3, 'aaaaa');
...
@@ -285,3 +285,50 @@ INSERT INTO t1 VALUES (3, 'aaaaa');
INSERT
INTO
t1
VALUES
(
2
,
'eeeeeee'
);
INSERT
INTO
t1
VALUES
(
2
,
'eeeeeee'
);
select
distinct
left
(
name
,
1
)
as
name
from
t1
;
select
distinct
left
(
name
,
1
)
as
name
from
t1
;
drop
table
t1
;
drop
table
t1
;
#
# Test case from sel000100
#
CREATE
TABLE
t1
(
ID
int
(
11
)
NOT
NULL
auto_increment
,
NAME
varchar
(
75
)
DEFAULT
''
NOT
NULL
,
LINK_ID
int
(
11
)
DEFAULT
'0'
NOT
NULL
,
PRIMARY
KEY
(
ID
),
KEY
NAME
(
NAME
),
KEY
LINK_ID
(
LINK_ID
)
);
INSERT
INTO
t1
(
ID
,
NAME
,
LINK_ID
)
VALUES
(
1
,
'Mike'
,
0
);
INSERT
INTO
t1
(
ID
,
NAME
,
LINK_ID
)
VALUES
(
2
,
'Jack'
,
0
);
INSERT
INTO
t1
(
ID
,
NAME
,
LINK_ID
)
VALUES
(
3
,
'Bill'
,
0
);
CREATE
TABLE
t2
(
ID
int
(
11
)
NOT
NULL
auto_increment
,
NAME
varchar
(
150
)
DEFAULT
''
NOT
NULL
,
PRIMARY
KEY
(
ID
),
KEY
NAME
(
NAME
)
);
SELECT
DISTINCT
t2
.
id
AS
key_link_id
,
t2
.
name
AS
link
FROM
t1
LEFT
JOIN
t2
ON
t1
.
link_id
=
t2
.
id
GROUP
BY
t1
.
id
ORDER
BY
link
;
drop
table
t1
,
t2
;
#
# test case for #674
#
CREATE
TABLE
t1
(
html
varchar
(
5
)
default
NULL
,
rin
int
(
11
)
default
'0'
,
out
int
(
11
)
default
'0'
)
TYPE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
'1'
,
1
,
0
);
SELECT
DISTINCT
html
,
SUM
(
out
)
/
(
SUM
(
rin
)
+
1
)
as
'prod'
FROM
t1
GROUP
BY
rin
;
drop
table
t1
;
mysql-test/t/range.test
View file @
04c43fca
...
@@ -217,3 +217,11 @@ explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
...
@@ -217,3 +217,11 @@ explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
explain
select
*
from
t1
force
index
(
i2
),
t2
where
(
t1
.
key1
<
t2
.
keya
+
1
)
and
t2
.
keya
=
3
;
explain
select
*
from
t1
force
index
(
i2
),
t2
where
(
t1
.
key1
<
t2
.
keya
+
1
)
and
t2
.
keya
=
3
;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
# test for a bug with in() and unique key
create
table
t1
(
id
int
(
10
)
primary
key
);
insert
into
t1
values
(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
),(
9
);
select
id
from
t1
where
id
in
(
2
,
5
,
9
)
;
select
id
from
t1
where
id
=
2
or
id
=
5
or
id
=
9
;
drop
table
t1
;
mysql-test/t/sel000033.test
deleted
100644 → 0
View file @
7538242e
# sel000033
#
# Versions
# --------
# 3.22
# 3.23
#
# Description
# -----------
# test for a bug with in() and unique key
--
disable_warnings
drop
table
if
exists
t1
;
--
enable_warnings
create
table
t1
(
id
int
(
10
)
primary
key
);
insert
into
t1
values
(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
),(
9
);
select
id
from
t1
where
id
in
(
2
,
5
,
9
)
;
select
id
from
t1
where
id
=
2
or
id
=
5
or
id
=
9
;
drop
table
t1
;
mysql-test/t/sel000100.test
deleted
100644 → 0
View file @
7538242e
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
,
t2
;
--
enable_warnings
CREATE
TABLE
t1
(
ID
int
(
11
)
NOT
NULL
auto_increment
,
NAME
varchar
(
75
)
DEFAULT
''
NOT
NULL
,
LINK_ID
int
(
11
)
DEFAULT
'0'
NOT
NULL
,
PRIMARY
KEY
(
ID
),
KEY
NAME
(
NAME
),
KEY
LINK_ID
(
LINK_ID
)
);
INSERT
INTO
t1
(
ID
,
NAME
,
LINK_ID
)
VALUES
(
1
,
'Mike'
,
0
);
INSERT
INTO
t1
(
ID
,
NAME
,
LINK_ID
)
VALUES
(
2
,
'Jack'
,
0
);
INSERT
INTO
t1
(
ID
,
NAME
,
LINK_ID
)
VALUES
(
3
,
'Bill'
,
0
);
CREATE
TABLE
t2
(
ID
int
(
11
)
NOT
NULL
auto_increment
,
NAME
varchar
(
150
)
DEFAULT
''
NOT
NULL
,
PRIMARY
KEY
(
ID
),
KEY
NAME
(
NAME
)
);
SELECT
DISTINCT
t2
.
id
AS
key_link_id
,
t2
.
name
AS
link
FROM
t1
LEFT
JOIN
t2
ON
t1
.
link_id
=
t2
.
id
GROUP
BY
t1
.
id
ORDER
BY
link
;
drop
table
t1
,
t2
;
#
# test case for #674
#
CREATE
TABLE
t1
(
html
varchar
(
5
)
default
NULL
,
rin
int
(
11
)
default
'0'
,
out
int
(
11
)
default
'0'
)
TYPE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
'1'
,
1
,
0
);
SELECT
DISTINCT
html
,
SUM
(
out
)
/
(
SUM
(
rin
)
+
1
)
as
'prod'
FROM
t1
GROUP
BY
rin
;
drop
table
t1
;
sql/log_event.cc
View file @
04c43fca
...
@@ -875,7 +875,6 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db)
...
@@ -875,7 +875,6 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db)
int
Query_log_event
::
exec_event
(
struct
st_relay_log_info
*
rli
)
int
Query_log_event
::
exec_event
(
struct
st_relay_log_info
*
rli
)
{
{
int
expected_error
,
actual_error
=
0
;
int
expected_error
,
actual_error
=
0
;
init_sql_alloc
(
&
thd
->
mem_root
,
8192
,
0
);
thd
->
db
=
(
char
*
)
rewrite_db
(
db
);
thd
->
db
=
(
char
*
)
rewrite_db
(
db
);
/*
/*
...
@@ -1589,7 +1588,6 @@ void Load_log_event::set_fields(List<Item> &field_list)
...
@@ -1589,7 +1588,6 @@ void Load_log_event::set_fields(List<Item> &field_list)
int
Load_log_event
::
exec_event
(
NET
*
net
,
struct
st_relay_log_info
*
rli
,
int
Load_log_event
::
exec_event
(
NET
*
net
,
struct
st_relay_log_info
*
rli
,
bool
use_rli_only_for_errors
)
bool
use_rli_only_for_errors
)
{
{
init_sql_alloc
(
&
thd
->
mem_root
,
8192
,
0
);
thd
->
db
=
(
char
*
)
rewrite_db
(
db
);
thd
->
db
=
(
char
*
)
rewrite_db
(
db
);
DBUG_ASSERT
(
thd
->
query
==
0
);
DBUG_ASSERT
(
thd
->
query
==
0
);
thd
->
query
=
0
;
// Should not be needed
thd
->
query
=
0
;
// Should not be needed
...
...
sql/sql_select.cc
View file @
04c43fca
...
@@ -2185,9 +2185,9 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
...
@@ -2185,9 +2185,9 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
if
(
cond_func
->
key_item
()
->
real_item
()
->
type
()
==
Item
::
FIELD_ITEM
&&
if
(
cond_func
->
key_item
()
->
real_item
()
->
type
()
==
Item
::
FIELD_ITEM
&&
!
(
cond_func
->
used_tables
()
&
OUTER_REF_TABLE_BIT
))
!
(
cond_func
->
used_tables
()
&
OUTER_REF_TABLE_BIT
))
add_key_field
(
key_fields
,
*
and_level
,
add_key_field
(
key_fields
,
*
and_level
,
((
Item_field
*
)
(
cond_func
->
key_item
()
->
real_item
()))
->
field
,
0
,
((
Item_field
*
)
(
cond_func
->
key_item
()
->
real_item
()))
->
field
,
0
,
cond_func
->
arguments
()
+
1
,
cond_func
->
argument_count
()
-
1
,
cond_func
->
arguments
()
+
1
,
cond_func
->
argument_count
()
-
1
,
#endif
usable_tables
);
usable_tables
);
break
;
break
;
case
Item_func
:
:
OPTIMIZE_OP
:
case
Item_func
:
:
OPTIMIZE_OP
:
...
@@ -3356,8 +3356,11 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
...
@@ -3356,8 +3356,11 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
OPTION_FOUND_ROWS
?
OPTION_FOUND_ROWS
?
HA_POS_ERROR
:
HA_POS_ERROR
:
join
->
unit
->
select_limit_cnt
))
<
0
)
join
->
unit
->
select_limit_cnt
))
<
0
)
{
/* before reporting "Impossible WHERE" for the whole query
{
we have to check isn't it only "impossible ON" instead */
/*
Before reporting "Impossible WHERE" for the whole query
we have to check isn't it only "impossible ON" instead
*/
sel
->
cond
=
orig_cond
;
sel
->
cond
=
orig_cond
;
if
(
!
tab
->
on_expr
||
if
(
!
tab
->
on_expr
||
sel
->
test_quick_select
(
tab
->
keys
,
sel
->
test_quick_select
(
tab
->
keys
,
...
@@ -3365,8 +3368,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
...
@@ -3365,8 +3368,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
(
join
->
select_options
&
(
join
->
select_options
&
OPTION_FOUND_ROWS
?
OPTION_FOUND_ROWS
?
HA_POS_ERROR
:
HA_POS_ERROR
:
join
->
thd
->
select_limi
t
))
<
0
)
join
->
unit
->
select_limit_cn
t
))
<
0
)
DBUG_RETURN
(
1
);
// Impossible WHERE
DBUG_RETURN
(
1
);
// Impossible WHERE
}
}
else
else
sel
->
cond
=
orig_cond
;
sel
->
cond
=
orig_cond
;
...
...
strings/ctype-tis620.c
View file @
04c43fca
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000
-2003
MySQL AB
This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
...
@@ -51,10 +51,7 @@
...
@@ -51,10 +51,7 @@
#ifdef HAVE_CHARSET_tis620
#ifdef HAVE_CHARSET_tis620
static
uchar
*
thai2sortable
(
const
uchar
*
tstr
,
int
len
);
#define BUFFER_MULTIPLY 4
#define BUFFER_MULTIPLY 4
#define buffsize(s) (BUFFER_MULTIPLY * (strlen(s) + 1))
#define M L_MIDDLE
#define M L_MIDDLE
#define U L_UPPER
#define U L_UPPER
#define L L_LOWER
#define L L_LOWER
...
@@ -451,34 +448,50 @@ uchar NEAR sort_order_tis620[]=
...
@@ -451,34 +448,50 @@ uchar NEAR sort_order_tis620[]=
(
uchar
)
'\370'
,(
uchar
)
'\371'
,(
uchar
)
'\372'
,(
uchar
)
'\373'
,(
uchar
)
'\374'
,(
uchar
)
'\375'
,(
uchar
)
'\376'
,(
uchar
)
'\377'
,
(
uchar
)
'\370'
,(
uchar
)
'\371'
,(
uchar
)
'\372'
,(
uchar
)
'\373'
,(
uchar
)
'\374'
,(
uchar
)
'\375'
,(
uchar
)
'\376'
,(
uchar
)
'\377'
,
};
};
/* Convert thai string to "Standard C String Function" sortable string
Arg: const source string and length of converted string
Ret: Sortable string
*/
/*
/*
NOTE: isn't it faster to alloc buffer in calling function?
Convert thai string to "Standard C String Function" sortable string
*/
static
uchar
*
thai2sortable
(
const
uchar
*
tstr
,
int
len
)
{
/* We use only 3 levels (neglect capitalization). */
const
uchar
*
p
=
tstr
;
SYNOPSIS
thai2sortable()
tstr String to convert. Does not have to end with \0
len Length of tstr
out_length Will contain length of sortable string
NOTE
We use only 3 levels (neglect capitalization).
OPTIMIZE SUGGESTION
Should be faster to alloc buffer in calling function.
RETURN
Pointer to sortable string. Should be freed with 'free'
*/
static
uchar
*
thai2sortable
(
const
uchar
*
tstr
,
uint
len
,
uint
*
out_length
)
{
const
uchar
*
p
=
tstr
;
uchar
*
outBuf
;
uchar
*
outBuf
;
uchar
*
pRight1
,
*
pRight2
,
*
pRight3
;
uchar
*
pRight1
,
*
pRight2
,
*
pRight3
;
uchar
*
pLeft1
,
*
pLeft2
,
*
pLeft3
;
uchar
*
pLeft1
,
*
pLeft2
,
*
pLeft3
;
uint
bufSize
;
uint
bufSize
;
uint
RightSize
;
uint
RightSize
;
len
=
(
int
)
strnlen
((
char
*
)
tstr
,
len
);
bufSize
=
(
uint
)
(
len
+
1
)
*
BUFFER_MULTIPLY
;
bufSize
=
(
uint
)
buffsize
((
char
*
)
tstr
);
RightSize
=
sizeof
(
uchar
)
*
(
len
+
1
);
RightSize
=
sizeof
(
uchar
)
*
(
len
+
1
);
if
(
!
(
outBuf
=
pLeft1
=
pRight1
=
if
(
!
(
outBuf
=
pLeft1
=
pRight1
=
(
uchar
*
)
malloc
(
sizeof
(
uchar
)
*
bufSize
+
RightSize
*
2
)))
(
uchar
*
)
malloc
(
sizeof
(
uchar
)
*
bufSize
+
RightSize
*
2
)))
{
/*
Can't allocate buffer; Use original string for sorting
This is not perfect, but better than nothing...
*/
*
out_length
=
len
;
return
(
uchar
*
)
tstr
;
return
(
uchar
*
)
tstr
;
}
pLeft2
=
pRight2
=
pRight1
+
sizeof
(
uchar
)
*
bufSize
;
pLeft2
=
pRight2
=
pRight1
+
sizeof
(
uchar
)
*
bufSize
;
pLeft3
=
pRight3
=
pRight2
+
RightSize
;
pLeft3
=
pRight3
=
pRight2
+
RightSize
;
while
(
--
len
>
0
)
while
(
(
int
)
--
len
>
0
)
{
{
int
*
t_ctype0
=
t_ctype
[
p
[
0
]];
int
*
t_ctype0
=
t_ctype
[
p
[
0
]];
if
(
isldvowel
(
*
p
)
&&
isconsnt
(
p
[
1
]))
if
(
isldvowel
(
*
p
)
&&
isconsnt
(
p
[
1
]))
...
@@ -507,17 +520,14 @@ static uchar* thai2sortable(const uchar * tstr,int len)
...
@@ -507,17 +520,14 @@ static uchar* thai2sortable(const uchar * tstr,int len)
p
++
;
p
++
;
}
}
}
}
if
(
!
len
)
if
(
!
len
)
/* If last was not double byte */
{
{
int
*
t_ctype0
=
t_ctype
[
p
[
0
]];
int
*
t_ctype0
=
t_ctype
[
p
[
0
]];
*
pRight1
=
t_ctype0
[
0
];
if
((
*
pRight1
=
t_ctype0
[
0
]
!=
IGNORE
))
if
(
*
pRight1
!=
IGNORE
)
pRight1
++
;
pRight1
++
;
*
pRight2
=
t_ctype0
[
1
];
if
((
*
pRight2
=
t_ctype0
[
1
])
!=
IGNORE
)
if
(
*
pRight2
!=
IGNORE
)
pRight2
++
;
pRight2
++
;
*
pRight3
=
t_ctype0
[
2
];
if
((
*
pRight3
=
t_ctype0
[
2
])
!=
IGNORE
)
if
(
*
pRight3
!=
IGNORE
)
pRight3
++
;
pRight3
++
;
}
}
*
pRight1
++=
L2_BLANK
;
*
pRight1
++=
L2_BLANK
;
...
@@ -526,31 +536,45 @@ static uchar* thai2sortable(const uchar * tstr,int len)
...
@@ -526,31 +536,45 @@ static uchar* thai2sortable(const uchar * tstr,int len)
memcpy
(
pRight1
,
pLeft2
,
pRight2
-
pLeft2
);
memcpy
(
pRight1
,
pLeft2
,
pRight2
-
pLeft2
);
pRight1
+=
pRight2
-
pLeft2
;
pRight1
+=
pRight2
-
pLeft2
;
memcpy
(
pRight1
,
pLeft3
,
pRight3
-
pLeft3
);
memcpy
(
pRight1
,
pLeft3
,
pRight3
-
pLeft3
);
*
out_length
=
(
uint
)
((
pRight1
+
(
uint
)
(
pRight3
-
pLeft3
))
-
outBuf
);
return
outBuf
;
return
outBuf
;
}
}
/* strncoll() replacement, compare 2 string, both are conveted to sortable string
Arg: 2 Strings and it compare length
/*
Ret: strcmp result
strncoll() replacement, compare 2 string, both are conveted to sortable
string
Arg: 2 Strings and it compare length
Ret: strcmp result
*/
*/
int
my_strnncoll_tis620
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
int
my_strnncoll_tis620
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
const
uchar
*
s1
,
uint
len1
,
const
uchar
*
s1
,
uint
len1
,
const
uchar
*
s2
,
uint
len2
)
const
uchar
*
s2
,
uint
len2
)
{
{
uchar
*
tc1
,
*
tc2
;
uchar
*
tc1
,
*
tc2
;
int
i
;
uint
tc1_length
,
tc2_length
,
length
;
tc1
=
thai2sortable
(
s1
,
len1
);
int
res
;
tc2
=
thai2sortable
(
s2
,
len2
);
i
=
strcmp
((
char
*
)
tc1
,
(
char
*
)
tc2
);
tc1
=
thai2sortable
(
s1
,
len1
,
&
tc1_length
);
free
(
tc1
);
tc2
=
thai2sortable
(
s2
,
len2
,
&
tc2_length
);
free
(
tc2
);
length
=
min
(
tc1_length
,
tc2_length
);
return
i
;
res
=
memcmp
((
char
*
)
tc1
,
(
char
*
)
tc2
,
length
);
if
(
tc1
!=
s1
)
free
(
tc1
);
if
(
tc2
!=
s2
)
free
(
tc2
);
return
(
res
||
tc1_length
==
tc2_length
?
res
:
(
tc1_length
<
tc2_length
?
-
1
:
1
));
}
}
static
static
int
my_strnncollsp_tis620
(
CHARSET_INFO
*
cs
,
int
my_strnncollsp_tis620
(
CHARSET_INFO
*
cs
,
const
uchar
*
s
,
uint
slen
,
const
uchar
*
s
,
uint
slen
,
const
uchar
*
t
,
uint
tlen
)
const
uchar
*
t
,
uint
tlen
)
{
{
for
(
;
slen
&&
my_isspace
(
cs
,
s
[
slen
-
1
])
;
slen
--
);
for
(
;
slen
&&
my_isspace
(
cs
,
s
[
slen
-
1
])
;
slen
--
);
for
(
;
tlen
&&
my_isspace
(
cs
,
t
[
tlen
-
1
])
;
tlen
--
);
for
(
;
tlen
&&
my_isspace
(
cs
,
t
[
tlen
-
1
])
;
tlen
--
);
...
@@ -566,63 +590,48 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)),
...
@@ -566,63 +590,48 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)),
uchar
*
dest
,
uint
len
,
uchar
*
dest
,
uint
len
,
const
uchar
*
src
,
uint
srclen
)
const
uchar
*
src
,
uint
srclen
)
{
{
uint
bufSize
;
uint
out_length
;
uchar
*
tmp
;
uchar
*
tmp
=
thai2sortable
(
src
,
srclen
,
&
out_length
)
;
bufSize
=
(
uint
)
buffsize
((
char
*
)
src
);
tmp
=
thai2sortable
(
src
,
src
len
);
set_if_smaller
(
out_length
,
len
);
set_if_smaller
(
bufSize
,(
uint
)
len
);
memcpy
(
dest
,
tmp
,
out_length
);
memcpy
((
uchar
*
)
dest
,
tmp
,
bufSize
);
if
(
tmp
!=
src
)
free
(
tmp
);
free
(
tmp
);
return
(
int
)
bufSize
;
return
(
int
)
out_length
;
}
}
/* strcoll replacment, compare 2 strings
/* strcoll replacment, compare 2 strings
Arg: 2 strings
Arg: 2 strings
Ret:
str
cmp result
Ret:
mem
cmp result
*/
*/
int
my_strcoll_tis620
(
const
uchar
*
s1
,
const
uchar
*
s2
)
int
my_strcoll_tis620
(
const
uchar
*
s1
,
const
uchar
*
s2
)
{
{
uchar
*
tc1
,
*
tc2
;
return
my_strnncoll_tis620
((
CHARSET_INFO
*
)
0
,
s1
,
strlen
(
s1
),
s2
,
int
i
;
strlen
(
s1
));
tc1
=
thai2sortable
(
s1
,
(
int
)
strlen
((
char
*
)
s1
));
tc2
=
thai2sortable
(
s2
,
(
int
)
strlen
((
char
*
)
s2
));
i
=
strcmp
((
char
*
)
tc1
,
(
char
*
)
tc2
);
free
(
tc1
);
free
(
tc2
);
return
i
;
}
}
/* strxfrm replacment, convert Thai string to sortable string
Arg: Destination buffer, String and dest buffer size
Ret: Converting string size
*/
int
my_strxfrm_tis620
(
uchar
*
dest
,
const
uchar
*
src
,
int
len
)
{
uint
bufSize
;
uchar
*
tmp
;
bufSize
=
(
uint
)
buffsize
((
char
*
)
src
);
tmp
=
thai2sortable
(
src
,
len
);
memcpy
((
uchar
*
)
dest
,
tmp
,
bufSize
);
free
(
tmp
);
return
bufSize
;
}
/* Convert SQL like string to C string
/*
Arg: String, its length, escape character, resource length, minimal string and maximum string
Convert SQL LIKE string to C string
Ret: Alway 0
IMPLEMENTATION
We just copy this function from opt_range.cc. No need to convert to
thai2sortable string. min_str and max_str will be use for comparison and
converted there.
RETURN VALUES
0
*/
*/
/* We just copy this function from opt_range.cc. No need to convert to
thai2sortable string. min_str and max_str will be use for comparison and
converted there. */
#define max_sort_chr ((char) 255)
#define max_sort_chr ((char) 255)
my_bool
my_like_range_tis620
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
my_bool
my_like_range_tis620
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
const
char
*
ptr
,
uint
ptr_length
,
const
char
*
ptr
,
uint
ptr_length
,
int
escape
,
int
w_one
,
int
w_many
,
int
escape
,
int
w_one
,
int
w_many
,
uint
res_length
,
char
*
min_str
,
char
*
max_str
,
uint
res_length
,
char
*
min_str
,
char
*
max_str
,
uint
*
min_length
,
uint
*
max_length
)
uint
*
min_length
,
uint
*
max_length
)
{
{
const
char
*
end
=
ptr
+
ptr_length
;
const
char
*
end
=
ptr
+
ptr_length
;
char
*
min_org
=
min_str
;
char
*
min_org
=
min_str
;
...
@@ -636,18 +645,18 @@ my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
...
@@ -636,18 +645,18 @@ my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
*
min_str
++
=
*
max_str
++
=
*
ptr
;
*
min_str
++
=
*
max_str
++
=
*
ptr
;
continue
;
continue
;
}
}
if
(
*
ptr
==
w_one
)
/* '_' in SQL */
if
(
*
ptr
==
w_one
)
/* '_' in SQL */
{
{
*
min_str
++=
'\0'
;
/* This should be min char */
*
min_str
++=
'\0'
;
/* This should be min char */
*
max_str
++=
max_sort_chr
;
*
max_str
++=
max_sort_chr
;
continue
;
continue
;
}
}
if
(
*
ptr
==
w_many
)
/* '%' in SQL */
if
(
*
ptr
==
w_many
)
/* '%' in SQL */
{
{
*
min_length
=
(
uint
)
(
min_str
-
min_org
);
*
min_length
=
(
uint
)
(
min_str
-
min_org
);
*
max_length
=
res_length
;
*
max_length
=
res_length
;
do
{
do
{
*
min_str
++
=
' '
;
/*
Because if
key compression */
*
min_str
++
=
' '
;
/*
For
key compression */
*
max_str
++
=
max_sort_chr
;
*
max_str
++
=
max_sort_chr
;
}
while
(
min_str
!=
min_end
);
}
while
(
min_str
!=
min_end
);
return
0
;
return
0
;
...
@@ -657,14 +666,18 @@ my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
...
@@ -657,14 +666,18 @@ my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
*
min_length
=
*
max_length
=
(
uint
)
(
min_str
-
min_org
);
*
min_length
=
*
max_length
=
(
uint
)
(
min_str
-
min_org
);
while
(
min_str
!=
min_end
)
while
(
min_str
!=
min_end
)
*
min_str
++
=
*
max_str
++
=
' '
;
/*
Because if
key compression */
*
min_str
++
=
*
max_str
++
=
' '
;
/*
For
key compression */
return
0
;
return
0
;
}
}
/* Thai normalization for input sub system
#ifdef NOT_NEEDED
Arg: Buffer, 's length, String, 'length
Ret: Void
/*
Thai normalization for input sub system
Arg: Buffer, 's length, String, 'length
Ret: Void
*/
*/
void
ThNormalize
(
uchar
*
ptr
,
uint
field_length
,
const
uchar
*
from
,
uint
length
)
void
ThNormalize
(
uchar
*
ptr
,
uint
field_length
,
const
uchar
*
from
,
uint
length
)
{
{
const
uchar
*
fr
=
from
;
const
uchar
*
fr
=
from
;
...
@@ -686,6 +699,7 @@ void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length)
...
@@ -686,6 +699,7 @@ void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length)
else
else
*
p
++
=
*
fr
++
;
*
p
++
=
*
fr
++
;
}
}
#endif
/* NOT_NEEDED */
static
MY_COLLATION_HANDLER
my_collation_ci_handler
=
static
MY_COLLATION_HANDLER
my_collation_ci_handler
=
...
...
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