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
518745ab
Commit
518745ab
authored
Aug 04, 2005
by
patg@krsna.patg.net
Browse files
Options
Browse Files
Download
Plain Diff
Merge pgalbraith@bk-internal.mysql.com:/home/bk/mysql-4.0
into krsna.patg.net:/home/patg/mysql-build/mysql-4.0
parents
08302a43
8109934e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
170 additions
and
2 deletions
+170
-2
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+117
-0
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+39
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+14
-2
No files found.
mysql-test/r/func_str.result
View file @
518745ab
...
...
@@ -38,6 +38,123 @@ www. .se
select substring_index('.tcx.se','.',-2),substring_index('.tcx.se','.tcx',-1);
substring_index('.tcx.se','.',-2) substring_index('.tcx.se','.tcx',-1)
tcx.se .se
select substring_index('aaaaaaaaa1','a',1);
substring_index('aaaaaaaaa1','a',1)
select substring_index('aaaaaaaaa1','aa',1);
substring_index('aaaaaaaaa1','aa',1)
select substring_index('aaaaaaaaa1','aa',2);
substring_index('aaaaaaaaa1','aa',2)
aa
select substring_index('aaaaaaaaa1','aa',3);
substring_index('aaaaaaaaa1','aa',3)
aaaa
select substring_index('aaaaaaaaa1','aa',4);
substring_index('aaaaaaaaa1','aa',4)
aaaaaa
select substring_index('aaaaaaaaa1','aa',5);
substring_index('aaaaaaaaa1','aa',5)
aaaaaaaaa1
select substring_index('aaaaaaaaa1','aaa',1);
substring_index('aaaaaaaaa1','aaa',1)
select substring_index('aaaaaaaaa1','aaa',2);
substring_index('aaaaaaaaa1','aaa',2)
aaa
select substring_index('aaaaaaaaa1','aaa',3);
substring_index('aaaaaaaaa1','aaa',3)
aaaaaa
select substring_index('aaaaaaaaa1','aaa',4);
substring_index('aaaaaaaaa1','aaa',4)
aaaaaaaaa1
select substring_index('aaaaaaaaa1','aaaa',1);
substring_index('aaaaaaaaa1','aaaa',1)
select substring_index('aaaaaaaaa1','aaaa',2);
substring_index('aaaaaaaaa1','aaaa',2)
aaaa
select substring_index('aaaaaaaaa1','1',1);
substring_index('aaaaaaaaa1','1',1)
aaaaaaaaa
select substring_index('aaaaaaaaa1','a',-1);
substring_index('aaaaaaaaa1','a',-1)
1
select substring_index('aaaaaaaaa1','aa',-1);
substring_index('aaaaaaaaa1','aa',-1)
1
select substring_index('aaaaaaaaa1','aa',-2);
substring_index('aaaaaaaaa1','aa',-2)
aa1
select substring_index('aaaaaaaaa1','aa',-3);
substring_index('aaaaaaaaa1','aa',-3)
aaaa1
select substring_index('aaaaaaaaa1','aa',-4);
substring_index('aaaaaaaaa1','aa',-4)
aaaaaa1
select substring_index('aaaaaaaaa1','aa',-5);
substring_index('aaaaaaaaa1','aa',-5)
aaaaaaaaa1
select substring_index('aaaaaaaaa1','aaa',-1);
substring_index('aaaaaaaaa1','aaa',-1)
1
select substring_index('aaaaaaaaa1','aaa',-2);
substring_index('aaaaaaaaa1','aaa',-2)
aaa1
select substring_index('aaaaaaaaa1','aaa',-3);
substring_index('aaaaaaaaa1','aaa',-3)
aaaaaa1
select substring_index('aaaaaaaaa1','aaa',-4);
substring_index('aaaaaaaaa1','aaa',-4)
select substring_index('the king of thethe hill','the',-2);
substring_index('the king of thethe hill','the',-2)
the hill
select substring_index('the king of the the hill','the',-2);
substring_index('the king of the the hill','the',-2)
the hill
select substring_index('the king of the the hill','the',-2);
substring_index('the king of the the hill','the',-2)
the hill
select substring_index('the king of the the hill',' the ',-1);
substring_index('the king of the the hill',' the ',-1)
hill
select substring_index('the king of the the hill',' the ',-2);
substring_index('the king of the the hill',' the ',-2)
the hill
select substring_index('the king of the the hill',' ',-1);
substring_index('the king of the the hill',' ',-1)
hill
select substring_index('the king of the the hill',' ',-2);
substring_index('the king of the the hill',' ',-2)
the hill
select substring_index('the king of the the hill',' ',-3);
substring_index('the king of the the hill',' ',-3)
the hill
select substring_index('the king of the the hill',' ',-4);
substring_index('the king of the the hill',' ',-4)
the the hill
select substring_index('the king of the the hill',' ',-5);
substring_index('the king of the the hill',' ',-5)
of the the hill
select substring_index('the king of the.the hill','the',-2);
substring_index('the king of the.the hill','the',-2)
.the hill
select substring_index('the king of thethethe.the hill','the',-3);
substring_index('the king of thethethe.the hill','the',-3)
the.the hill
select substring_index('the king of thethethe.the hill','the',-1);
substring_index('the king of thethethe.the hill','the',-1)
hill
select substring_index('the king of the the hill','the',1);
substring_index('the king of the the hill','the',1)
select substring_index('the king of the the hill','the',2);
substring_index('the king of the the hill','the',2)
the king of
select substring_index('the king of the the hill','the',3);
substring_index('the king of the the hill','the',3)
the king of the
select concat(':',ltrim(' left '),':',rtrim(' right '),':');
concat(':',ltrim(' left '),':',rtrim(' right '),':')
:left : right:
...
...
mysql-test/t/func_str.test
View file @
518745ab
...
...
@@ -19,6 +19,45 @@ select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',s
select
substring_index
(
'www.tcx.se'
,
'.'
,
-
2
),
substring_index
(
'www.tcx.se'
,
'.'
,
1
);
select
substring_index
(
'www.tcx.se'
,
'tcx'
,
1
),
substring_index
(
'www.tcx.se'
,
'tcx'
,
-
1
);
select
substring_index
(
'.tcx.se'
,
'.'
,
-
2
),
substring_index
(
'.tcx.se'
,
'.tcx'
,
-
1
);
select
substring_index
(
'aaaaaaaaa1'
,
'a'
,
1
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
1
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
2
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
3
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
4
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
5
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaa'
,
1
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaa'
,
2
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaa'
,
3
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaa'
,
4
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaaa'
,
1
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaaa'
,
2
);
select
substring_index
(
'aaaaaaaaa1'
,
'1'
,
1
);
select
substring_index
(
'aaaaaaaaa1'
,
'a'
,
-
1
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
-
1
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
-
2
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
-
3
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
-
4
);
select
substring_index
(
'aaaaaaaaa1'
,
'aa'
,
-
5
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaa'
,
-
1
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaa'
,
-
2
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaa'
,
-
3
);
select
substring_index
(
'aaaaaaaaa1'
,
'aaa'
,
-
4
);
select
substring_index
(
'the king of thethe hill'
,
'the'
,
-
2
);
select
substring_index
(
'the king of the the hill'
,
'the'
,
-
2
);
select
substring_index
(
'the king of the the hill'
,
'the'
,
-
2
);
select
substring_index
(
'the king of the the hill'
,
' the '
,
-
1
);
select
substring_index
(
'the king of the the hill'
,
' the '
,
-
2
);
select
substring_index
(
'the king of the the hill'
,
' '
,
-
1
);
select
substring_index
(
'the king of the the hill'
,
' '
,
-
2
);
select
substring_index
(
'the king of the the hill'
,
' '
,
-
3
);
select
substring_index
(
'the king of the the hill'
,
' '
,
-
4
);
select
substring_index
(
'the king of the the hill'
,
' '
,
-
5
);
select
substring_index
(
'the king of the.the hill'
,
'the'
,
-
2
);
select
substring_index
(
'the king of thethethe.the hill'
,
'the'
,
-
3
);
select
substring_index
(
'the king of thethethe.the hill'
,
'the'
,
-
1
);
select
substring_index
(
'the king of the the hill'
,
'the'
,
1
);
select
substring_index
(
'the king of the the hill'
,
'the'
,
2
);
select
substring_index
(
'the king of the the hill'
,
'the'
,
3
);
select
concat
(
':'
,
ltrim
(
' left '
),
':'
,
rtrim
(
' right '
),
':'
);
select
concat
(
':'
,
trim
(
LEADING
FROM
' left'
),
':'
,
trim
(
TRAILING
FROM
' right '
),
':'
);
...
...
sql/item_strfunc.cc
View file @
518745ab
...
...
@@ -1084,11 +1084,23 @@ String *Item_func_substr_index::val_str(String *str)
}
}
else
{
// Start counting at end
for
(
offset
=
res
->
length
()
;
;
offset
-=
delimeter_length
-
1
)
{
/*
Negative index, start counting at the end
*/
for
(
offset
=
res
->
length
();
offset
;)
{
/*
this call will result in finding the position pointing to one
address space less than where the found substring is located
in res
*/
if
((
int
)
(
offset
=
res
->
strrstr
(
*
delimeter
,
offset
))
<
0
)
return
res
;
// Didn't find, return org string
/*
At this point, we've searched for the substring
the number of times as supplied by the index value
*/
if
(
!++
count
)
{
offset
+=
delimeter_length
;
...
...
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