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
76ed2fc4
Commit
76ed2fc4
authored
Nov 14, 2002
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed unused function
some bug fixes
parent
237e2ca0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
246 deletions
+11
-246
include/m_ctype.h
include/m_ctype.h
+1
-1
mysys/charset.c
mysys/charset.c
+1
-0
sql/mysql_priv.h
sql/mysql_priv.h
+0
-4
sql/slave.cc
sql/slave.cc
+3
-2
sql/sql_string.cc
sql/sql_string.cc
+6
-239
No files found.
include/m_ctype.h
View file @
76ed2fc4
...
...
@@ -232,7 +232,7 @@ int my_wildcmp_mb(CHARSET_INFO *,
#define my_strnncoll(s, a, b, c, d) ((s)->strnncoll((s), (a), (b), (c), (d)))
#define my_like_range(s, a, b, c, d, e, f, g, h) \
((s)->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h)))
#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->wildcmp
,(s),(se),(w),(we),(e),(o),(m
))
#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->wildcmp
((cs),(s),(se),(w),(we),(e),(o),(m)
))
#define use_mb(s) ((s)->ismbchar != NULL)
#define my_ismbchar(s, a, b) ((s)->ismbchar((s), (a), (b)))
...
...
mysys/charset.c
View file @
76ed2fc4
...
...
@@ -376,6 +376,7 @@ static CHARSET_INFO *add_charset(CHARSET_INFO *cs, myf flags)
sizeof
(
tmp_sort_order
));
memcpy
((
char
*
)
cs
->
tab_to_uni
,
(
char
*
)
tmp_to_uni
,
sizeof
(
tmp_to_uni
));
cs
->
wildcmp
=
my_wildcmp_8bit
;
cs
->
strnncoll
=
my_strnncoll_simple
;
cs
->
caseup_str
=
my_caseup_str_8bit
;
cs
->
casedn_str
=
my_casedn_str_8bit
;
...
...
sql/mysql_priv.h
View file @
76ed2fc4
...
...
@@ -817,10 +817,6 @@ bool check_column_name(const char *name);
bool
check_table_name
(
const
char
*
name
,
uint
length
);
char
*
get_field
(
MEM_ROOT
*
mem
,
TABLE
*
table
,
uint
fieldnr
);
int
wild_case_compare
(
CHARSET_INFO
*
cs
,
const
char
*
str
,
const
char
*
wildstr
);
int
wild_compare
(
const
char
*
str
,
const
char
*
str_end
,
const
char
*
wildstr
,
const
char
*
wildend
,
char
escape
);
int
wild_case_compare
(
CHARSET_INFO
*
cs
,
const
char
*
str
,
const
char
*
str_end
,
const
char
*
wildstr
,
const
char
*
wildend
,
char
escape
);
/* from hostname.cc */
struct
in_addr
;
...
...
sql/slave.cc
View file @
76ed2fc4
...
...
@@ -638,9 +638,10 @@ static TABLE_RULE_ENT* find_wild(DYNAMIC_ARRAY *a, const char* key, int len)
{
TABLE_RULE_ENT
*
e
;
get_dynamic
(
a
,
(
gptr
)
&
e
,
i
);
if
(
!
wild_case_compare
(
system_charset_info
,
key
,
key_end
,
if
(
!
my_wildcmp
(
system_charset_info
,
key
,
key_end
,
(
const
char
*
)
e
->
db
,
(
const
char
*
)(
e
->
db
+
e
->
key_len
),
'\\'
))
(
const
char
*
)(
e
->
db
+
e
->
key_len
),
'\\'
,
wild_one
,
wild_many
))
return
e
;
}
...
...
sql/sql_string.cc
View file @
76ed2fc4
...
...
@@ -671,151 +671,6 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
return
to
;
}
/* Make it easier to handle different charactersets */
#ifdef USE_MB
#define INC_PTR(cs,A,B) A+=((use_mb_flag && \
my_ismbchar(cs,A,B)) ? my_ismbchar(cs,A,B) : 1)
#else
#define INC_PTR(cs,A,B) A++
#endif
/*
** Compare string against string with wildcard
** 0 if matched
** -1 if not matched with wildcard
** 1 if matched with wildcard
*/
#ifdef LIKE_CMP_TOUPPER
#define likeconv(s,A) (uchar) my_toupper(s,A)
#else
#define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)]
#endif
int
wild_case_compare
(
CHARSET_INFO
*
cs
,
const
char
*
str
,
const
char
*
str_end
,
const
char
*
wildstr
,
const
char
*
wildend
,
char
escape
)
{
int
result
=
-
1
;
// Not found, using wildcards
#ifdef USE_MB
bool
use_mb_flag
=
use_mb
(
cs
);
#endif
while
(
wildstr
!=
wildend
)
{
while
(
*
wildstr
!=
wild_many
&&
*
wildstr
!=
wild_one
)
{
if
(
*
wildstr
==
escape
&&
wildstr
+
1
!=
wildend
)
wildstr
++
;
#ifdef USE_MB
int
l
;
if
(
use_mb_flag
&&
(
l
=
my_ismbchar
(
cs
,
wildstr
,
wildend
)))
{
if
(
str
+
l
>
str_end
||
memcmp
(
str
,
wildstr
,
l
)
!=
0
)
return
1
;
str
+=
l
;
wildstr
+=
l
;
}
else
#endif
if
(
str
==
str_end
||
likeconv
(
cs
,
*
wildstr
++
)
!=
likeconv
(
cs
,
*
str
++
))
return
(
1
);
// No match
if
(
wildstr
==
wildend
)
return
(
str
!=
str_end
);
// Match if both are at end
result
=
1
;
// Found an anchor char
}
if
(
*
wildstr
==
wild_one
)
{
do
{
if
(
str
==
str_end
)
// Skip one char if possible
return
(
result
);
INC_PTR
(
cs
,
str
,
str_end
);
}
while
(
++
wildstr
<
wildend
&&
*
wildstr
==
wild_one
);
if
(
wildstr
==
wildend
)
break
;
}
if
(
*
wildstr
==
wild_many
)
{
// Found wild_many
wildstr
++
;
/* Remove any '%' and '_' from the wild search string */
for
(;
wildstr
!=
wildend
;
wildstr
++
)
{
if
(
*
wildstr
==
wild_many
)
continue
;
if
(
*
wildstr
==
wild_one
)
{
if
(
str
==
str_end
)
return
(
-
1
);
INC_PTR
(
cs
,
str
,
str_end
);
continue
;
}
break
;
// Not a wild character
}
if
(
wildstr
==
wildend
)
return
(
0
);
// Ok if wild_many is last
if
(
str
==
str_end
)
return
-
1
;
uchar
cmp
;
if
((
cmp
=
*
wildstr
)
==
escape
&&
wildstr
+
1
!=
wildend
)
cmp
=
*++
wildstr
;
#ifdef USE_MB
const
char
*
mb
=
wildstr
;
int
mblen
;
LINT_INIT
(
mblen
);
if
(
use_mb_flag
)
mblen
=
my_ismbchar
(
cs
,
wildstr
,
wildend
);
#endif
INC_PTR
(
cs
,
wildstr
,
wildend
);
// This is compared trough cmp
cmp
=
likeconv
(
cs
,
cmp
);
do
{
#ifdef USE_MB
if
(
use_mb_flag
)
{
for
(;;)
{
if
(
str
>=
str_end
)
return
-
1
;
if
(
mblen
)
{
if
(
str
+
mblen
<=
str_end
&&
memcmp
(
str
,
mb
,
mblen
)
==
0
)
{
str
+=
mblen
;
break
;
}
}
else
if
(
!
my_ismbchar
(
cs
,
str
,
str_end
)
&&
likeconv
(
cs
,
*
str
)
==
cmp
)
{
str
++
;
break
;
}
INC_PTR
(
cs
,
str
,
str_end
);
}
}
else
{
#endif
/* USE_MB */
while
(
str
!=
str_end
&&
likeconv
(
cs
,
*
str
)
!=
cmp
)
str
++
;
if
(
str
++
==
str_end
)
return
(
-
1
);
#ifdef USE_MB
}
#endif
{
int
tmp
=
wild_case_compare
(
cs
,
str
,
str_end
,
wildstr
,
wildend
,
escape
);
if
(
tmp
<=
0
)
return
(
tmp
);
}
}
while
(
str
!=
str_end
&&
wildstr
[
0
]
!=
wild_many
);
return
(
-
1
);
}
}
return
(
str
!=
str_end
?
1
:
0
);
}
int
wild_case_compare
(
String
&
match
,
String
&
wild
,
char
escape
)
...
...
@@ -823,100 +678,11 @@ int wild_case_compare(String &match,String &wild, char escape)
DBUG_ENTER
(
"wild_case_compare"
);
DBUG_PRINT
(
"enter"
,(
"match='%s', wild='%s', escape='%c'"
,
match
.
ptr
(),
wild
.
ptr
(),
escape
));
DBUG_RETURN
(
wild_case_compare
(
match
.
str_charset
,
match
.
ptr
(),
match
.
ptr
()
+
match
.
length
(),
wild
.
ptr
(),
wild
.
ptr
()
+
wild
.
length
(),
escape
));
DBUG_RETURN
(
my_wildcmp
(
match
.
str_charset
,
match
.
ptr
(),
match
.
ptr
()
+
match
.
length
(),
wild
.
ptr
(),
wild
.
ptr
()
+
wild
.
length
(),
escape
,
wild_one
,
wild_many
));
}
/*
** The following is used when using LIKE on binary strings
*/
int
wild_compare
(
const
char
*
str
,
const
char
*
str_end
,
const
char
*
wildstr
,
const
char
*
wildend
,
char
escape
)
{
DBUG_ENTER
(
"wild_compare"
);
DBUG_PRINT
(
"enter"
,(
"str='%s', str_end='%s', wildstr='%s', wildend='%s', escape='%c'"
,
str
,
str_end
,
wildstr
,
wildend
,
escape
));
int
result
=
-
1
;
// Not found, using wildcards
while
(
wildstr
!=
wildend
)
{
while
(
*
wildstr
!=
wild_many
&&
*
wildstr
!=
wild_one
)
{
if
(
*
wildstr
==
escape
&&
wildstr
+
1
!=
wildend
)
wildstr
++
;
if
(
str
==
str_end
||
*
wildstr
++
!=
*
str
++
)
{
DBUG_RETURN
(
1
);
}
if
(
wildstr
==
wildend
)
{
DBUG_RETURN
(
str
!=
str_end
);
// Match if both are at end
}
result
=
1
;
// Found an anchor char
}
if
(
*
wildstr
==
wild_one
)
{
do
{
if
(
str
==
str_end
)
// Skip one char if possible
DBUG_RETURN
(
result
);
str
++
;
}
while
(
*++
wildstr
==
wild_one
&&
wildstr
!=
wildend
);
if
(
wildstr
==
wildend
)
break
;
}
if
(
*
wildstr
==
wild_many
)
{
// Found wild_many
wildstr
++
;
/* Remove any '%' and '_' from the wild search string */
for
(;
wildstr
!=
wildend
;
wildstr
++
)
{
if
(
*
wildstr
==
wild_many
)
continue
;
if
(
*
wildstr
==
wild_one
)
{
if
(
str
==
str_end
)
{
DBUG_RETURN
(
-
1
);
}
str
++
;
continue
;
}
break
;
// Not a wild character
}
if
(
wildstr
==
wildend
)
{
DBUG_RETURN
(
0
);
// Ok if wild_many is last
}
if
(
str
==
str_end
)
{
DBUG_RETURN
(
-
1
);
}
char
cmp
;
if
((
cmp
=
*
wildstr
)
==
escape
&&
wildstr
+
1
!=
wildend
)
cmp
=
*++
wildstr
;
wildstr
++
;
// This is compared trough cmp
do
{
while
(
str
!=
str_end
&&
*
str
!=
cmp
)
str
++
;
if
(
str
++
==
str_end
)
{
DBUG_RETURN
(
-
1
);
}
{
int
tmp
=
wild_compare
(
str
,
str_end
,
wildstr
,
wildend
,
escape
);
if
(
tmp
<=
0
)
{
DBUG_RETURN
(
tmp
);
}
}
}
while
(
str
!=
str_end
&&
wildstr
[
0
]
!=
wild_many
);
DBUG_RETURN
(
-
1
);
}
}
DBUG_RETURN
(
str
!=
str_end
?
1
:
0
);
}
int
wild_compare
(
String
&
match
,
String
&
wild
,
char
escape
)
...
...
@@ -924,8 +690,9 @@ int wild_compare(String &match,String &wild, char escape)
DBUG_ENTER
(
"wild_compare"
);
DBUG_PRINT
(
"enter"
,(
"match='%s', wild='%s', escape='%c'"
,
match
.
ptr
(),
wild
.
ptr
(),
escape
));
DBUG_RETURN
(
wild_compare
(
match
.
ptr
(),
match
.
ptr
()
+
match
.
length
(),
wild
.
ptr
(),
wild
.
ptr
()
+
wild
.
length
(),
escape
));
DBUG_RETURN
(
my_wildcmp
(
my_charset_bin
,
match
.
ptr
(),
match
.
ptr
()
+
match
.
length
(),
wild
.
ptr
(),
wild
.
ptr
()
+
wild
.
length
(),
escape
,
wild_one
,
wild_many
));
}
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