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
6e1c8ad8
Commit
6e1c8ad8
authored
Jul 06, 2006
by
igor@olga.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into olga.mysql.com:/home/igor/mysql-4.1-opt
parents
d581287b
0e3d2daf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
18 deletions
+54
-18
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+15
-0
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+17
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+21
-18
sql/item_strfunc.h
sql/item_strfunc.h
+1
-0
No files found.
mysql-test/r/func_str.result
View file @
6e1c8ad8
...
...
@@ -1021,4 +1021,19 @@ select * from t1 where f1='test' and (f2= sha("TEST") or f2= sha("test"));
f1 f2
test a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
drop table t1;
CREATE TABLE t1 (a varchar(10));
INSERT INTO t1 VALUES ('abc'), ('xyz');
SELECT a, CONCAT(a,' ',a) AS c FROM t1
HAVING LEFT(c,LENGTH(c)-INSTR(REVERSE(c)," ")) = a;
a c
abc abc abc
xyz xyz xyz
SELECT a, CONCAT(a,' ',a) AS c FROM t1
HAVING LEFT(CONCAT(a,' ',a),
LENGTH(CONCAT(a,' ',a))-
INSTR(REVERSE(CONCAT(a,' ',a))," ")) = a;
a c
abc abc abc
xyz xyz xyz
DROP TABLE t1;
End of 4.1 tests
mysql-test/t/func_str.test
View file @
6e1c8ad8
...
...
@@ -681,4 +681,21 @@ select * from t1 where f1='test' and (f2= sha("test") or f2= sha("TEST"));
select
*
from
t1
where
f1
=
'test'
and
(
f2
=
sha
(
"TEST"
)
or
f2
=
sha
(
"test"
));
drop
table
t1
;
#
# Bug#18243: REVERSE changes its argument
#
CREATE
TABLE
t1
(
a
varchar
(
10
));
INSERT
INTO
t1
VALUES
(
'abc'
),
(
'xyz'
);
SELECT
a
,
CONCAT
(
a
,
' '
,
a
)
AS
c
FROM
t1
HAVING
LEFT
(
c
,
LENGTH
(
c
)
-
INSTR
(
REVERSE
(
c
),
" "
))
=
a
;
SELECT
a
,
CONCAT
(
a
,
' '
,
a
)
AS
c
FROM
t1
HAVING
LEFT
(
CONCAT
(
a
,
' '
,
a
),
LENGTH
(
CONCAT
(
a
,
' '
,
a
))
-
INSTR
(
REVERSE
(
CONCAT
(
a
,
' '
,
a
)),
" "
))
=
a
;
DROP
TABLE
t1
;
--
echo
End
of
4.1
tests
sql/item_strfunc.cc
View file @
6e1c8ad8
...
...
@@ -709,44 +709,47 @@ String *Item_func_reverse::val_str(String *str)
{
DBUG_ASSERT
(
fixed
==
1
);
String
*
res
=
args
[
0
]
->
val_str
(
str
);
char
*
ptr
,
*
end
;
char
*
ptr
,
*
end
,
*
tmp
;
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
/* An empty string is a special case as the string pointer may be null */
if
(
!
res
->
length
())
return
&
my_empty_string
;
res
=
copy_if_not_alloced
(
str
,
res
,
res
->
length
());
ptr
=
(
char
*
)
res
->
ptr
();
end
=
ptr
+
res
->
length
();
if
(
tmp_value
.
alloced_length
()
<
res
->
length
()
&&
tmp_value
.
realloc
(
res
->
length
()))
{
null_value
=
1
;
return
0
;
}
tmp_value
.
length
(
res
->
length
());
tmp_value
.
set_charset
(
res
->
charset
());
ptr
=
(
char
*
)
res
->
ptr
();
end
=
ptr
+
res
->
length
();
tmp
=
(
char
*
)
tmp_value
.
ptr
()
+
tmp_value
.
length
();
#ifdef USE_MB
if
(
use_mb
(
res
->
charset
()))
{
String
tmpstr
;
tmpstr
.
copy
(
*
res
);
char
*
tmp
=
(
char
*
)
tmpstr
.
ptr
()
+
tmpstr
.
length
();
register
uint32
l
;
while
(
ptr
<
end
)
{
if
((
l
=
my_ismbchar
(
res
->
charset
(),
ptr
,
end
)))
tmp
-=
l
,
memcpy
(
tmp
,
ptr
,
l
),
ptr
+=
l
;
if
((
l
=
my_ismbchar
(
res
->
charset
(),
ptr
,
end
)))
{
tmp
-=
l
;
memcpy
(
tmp
,
ptr
,
l
);
ptr
+=
l
;
}
else
*--
tmp
=*
ptr
++
;
*--
tmp
=
*
ptr
++
;
}
memcpy
((
char
*
)
res
->
ptr
(),(
char
*
)
tmpstr
.
ptr
(),
res
->
length
());
}
else
#endif
/* USE_MB */
{
char
tmp
;
while
(
ptr
<
end
)
{
tmp
=*
ptr
;
*
ptr
++=*--
end
;
*
end
=
tmp
;
}
*--
tmp
=
*
ptr
++
;
}
return
res
;
return
&
tmp_value
;
}
...
...
sql/item_strfunc.h
View file @
6e1c8ad8
...
...
@@ -100,6 +100,7 @@ public:
class
Item_func_reverse
:
public
Item_str_func
{
String
tmp_value
;
public:
Item_func_reverse
(
Item
*
a
)
:
Item_str_func
(
a
)
{}
String
*
val_str
(
String
*
);
...
...
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