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
55b27888
Commit
55b27888
authored
Nov 09, 2020
by
Monty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed length estimate for REPLACE()
parent
657fcdf4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
4 deletions
+12
-4
mysql-test/main/func_str.result
mysql-test/main/func_str.result
+5
-0
mysql-test/main/func_str.test
mysql-test/main/func_str.test
+3
-0
mysql-test/main/null.result
mysql-test/main/null.result
+1
-1
sql/item_strfunc.cc
sql/item_strfunc.cc
+3
-3
No files found.
mysql-test/main/func_str.result
View file @
55b27888
...
...
@@ -211,6 +211,11 @@ this is test
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
replace('aaaa','a','b') replace('aaaa','aa','b') replace('aaaa','a','bb') replace('aaaa','','b') replace('bbbb','a','c')
bbbb bb bbbbbbbb aaaa bbbb
select replace('aaaa','a','bbbb');
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def replace('aaaa','a','bbbb') 253 16 16 Y 0 39 8
replace('aaaa','a','bbbb')
bbbbbbbbbbbbbbbb
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL')
this is a REAL test
...
...
mysql-test/main/func_str.test
View file @
55b27888
...
...
@@ -91,6 +91,9 @@ SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),r
select
insert
(
'txs'
,
2
,
1
,
'hi'
),
insert
(
'is '
,
4
,
0
,
'a'
),
insert
(
'txxxxt'
,
2
,
4
,
'es'
);
select
replace
(
'aaaa'
,
'a'
,
'b'
),
replace
(
'aaaa'
,
'aa'
,
'b'
),
replace
(
'aaaa'
,
'a'
,
'bb'
),
replace
(
'aaaa'
,
''
,
'b'
),
replace
(
'bbbb'
,
'a'
,
'c'
);
--
enable_metadata
select
replace
(
'aaaa'
,
'a'
,
'bbbb'
);
--
disable_metadata
select
replace
(
concat
(
lcase
(
concat
(
'THIS'
,
' '
,
'IS'
,
' '
,
'A'
,
' '
)),
ucase
(
'false'
),
' '
,
'test'
),
'FALSE'
,
'REAL'
)
;
select
soundex
(
''
),
soundex
(
'he'
),
soundex
(
'hello all folks'
),
soundex
(
'#3556 in bugdb'
);
select
'mood'
sounds
like
'mud'
;
...
...
mysql-test/main/null.result
View file @
55b27888
...
...
@@ -267,7 +267,7 @@ t1 CREATE TABLE `t1` (
`c30` varchar(317) CHARACTER SET latin2 DEFAULT NULL,
`c31` varchar(192) CHARACTER SET latin2 DEFAULT NULL,
`c32` char(0) CHARACTER SET latin2 DEFAULT NULL,
`c33` varchar(
3
) CHARACTER SET latin2 DEFAULT NULL,
`c33` varchar(
6
) CHARACTER SET latin2 DEFAULT NULL,
`c34` varchar(3) CHARACTER SET latin2 DEFAULT NULL,
`c35` varchar(3) CHARACTER SET latin2 DEFAULT NULL,
`c36` varchar(3) CHARACTER SET latin2 DEFAULT NULL,
...
...
sql/item_strfunc.cc
View file @
55b27888
...
...
@@ -1286,10 +1286,10 @@ String *Item_func_replace::val_str_internal(String *str,
bool
Item_func_replace
::
fix_length_and_dec
()
{
ulonglong
char_length
=
(
ulonglong
)
args
[
0
]
->
max_char_length
();
int
diff
=
(
int
)
(
args
[
2
]
->
max_char_length
()
-
args
[
1
]
->
max_char_length
()
);
if
(
diff
>
0
&&
args
[
1
]
->
max_char_length
()
)
int
diff
=
(
int
)
(
args
[
2
]
->
max_char_length
()
-
1
);
if
(
diff
>
0
)
{
// Calculate of maxreplaces
ulonglong
max_substrs
=
char_length
/
args
[
1
]
->
max_char_length
()
;
ulonglong
max_substrs
=
char_length
;
char_length
+=
max_substrs
*
(
uint
)
diff
;
}
...
...
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