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
fece177f
Commit
fece177f
authored
Aug 04, 2014
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysqltest: support pairs of delimiters in replace_regex
parent
ef2bf187
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
55 deletions
+49
-55
client/mysqltest.cc
client/mysqltest.cc
+37
-52
mysql-test/r/mysqltest.result
mysql-test/r/mysqltest.result
+3
-0
mysql-test/suite/rpl/t/rpl_sp.test
mysql-test/suite/rpl/t/rpl_sp.test
+1
-1
mysql-test/suite/sys_vars/t/report_port_basic.test
mysql-test/suite/sys_vars/t/report_port_basic.test
+1
-1
mysql-test/t/mysqltest.test
mysql-test/t/mysqltest.test
+7
-1
No files found.
client/mysqltest.cc
View file @
fece177f
...
...
@@ -9914,36 +9914,34 @@ struct st_regex
int
reg_replace
(
char
**
buf_p
,
int
*
buf_len_p
,
char
*
pattern
,
char
*
replace
,
char
*
string
,
int
icase
);
bool
parse_re_part
(
char
*
start_re
,
char
*
end_re
,
char
**
p
,
char
*
end
,
char
**
buf
)
{
if
(
*
start_re
!=
*
end_re
)
{
switch
((
*
start_re
=
*
(
*
p
)
++
))
{
case
'('
:
*
end_re
=
')'
;
break
;
case
'['
:
*
end_re
=
']'
;
break
;
case
'{'
:
*
end_re
=
'}'
;
break
;
case
'<'
:
*
end_re
=
'>'
;
break
;
default:
*
end_re
=
*
start_re
;
}
}
while
(
*
p
<
end
&&
**
p
!=
*
end_re
)
{
if
((
*
p
)[
0
]
==
'\\'
&&
*
p
+
1
<
end
&&
(
*
p
)[
1
]
==
*
end_re
)
(
*
p
)
++
;
/*
Finds the next (non-escaped) '/' in the expression.
(If the character '/' is needed, it can be escaped using '\'.)
*/
*
(
*
buf
)
++=
*
(
*
p
)
++
;
}
*
(
*
buf
)
++=
0
;
(
*
p
)
++
;
return
*
p
>
end
;
}
#define PARSE_REGEX_ARG \
while (p < expr_end) \
{ \
char c= *p; \
if (c == '/') \
{ \
if (last_c == '\\') \
{ \
buf_p[-1]= '/'; \
} \
else \
{ \
*buf_p++ = 0; \
break; \
} \
} \
else \
*buf_p++ = c; \
\
last_c= c; \
p++; \
} \
\
/*
Initializes the regular substitution expression to be used in the
result output of test.
...
...
@@ -9955,10 +9953,9 @@ struct st_replace_regex* init_replace_regex(char* expr)
{
struct
st_replace_regex
*
res
;
char
*
buf
,
*
expr_end
;
char
*
p
;
char
*
p
,
start_re
,
end_re
=
1
;
char
*
buf_p
;
uint
expr_len
=
strlen
(
expr
);
char
last_c
=
0
;
struct
st_regex
reg
;
/* my_malloc() will die on fail with MY_FAE */
...
...
@@ -9976,44 +9973,32 @@ struct st_replace_regex* init_replace_regex(char* expr)
{
bzero
(
&
reg
,
sizeof
(
reg
));
/* find the start of the statement */
while
(
p
<
expr_end
)
{
if
(
*
p
==
'/'
)
break
;
while
(
my_isspace
(
charset_info
,
*
p
)
&&
p
<
expr_end
)
p
++
;
}
if
(
p
==
expr_end
||
++
p
=
=
expr_end
)
if
(
p
>
=
expr_end
)
{
if
(
res
->
regex_arr
.
elements
)
break
;
else
goto
err
;
}
/* we found the start */
reg
.
pattern
=
buf_p
;
/* Find first argument -- pattern string to be removed */
PARSE_REGEX_ARG
if
(
p
==
expr_end
||
++
p
==
expr_end
)
goto
err
;
start_re
=
0
;
reg
.
pattern
=
buf_p
;
if
(
parse_re_part
(
&
start_re
,
&
end_re
,
&
p
,
expr_end
,
&
buf_p
))
goto
err
;
/* buf_p now points to the replacement pattern terminated with \0 */
reg
.
replace
=
buf_p
;
/* Find second argument -- replace string to replace pattern */
PARSE_REGEX_ARG
if
(
p
==
expr_end
)
goto
err
;
/* skip the ending '/' in the statement */
p
++
;
if
(
parse_re_part
(
&
start_re
,
&
end_re
,
&
p
,
expr_end
,
&
buf_p
))
goto
err
;
/* Check if we should do matching case insensitive */
if
(
p
<
expr_end
&&
*
p
==
'i'
)
{
p
++
;
reg
.
icase
=
1
;
}
/* done parsing the statement, now place it in regex_arr */
if
(
insert_dynamic
(
&
res
->
regex_arr
,(
uchar
*
)
&
reg
))
...
...
mysql-test/r/mysqltest.result
View file @
fece177f
...
...
@@ -680,6 +680,9 @@ txt
b is b and more is more
txt
a is a and less is more
sflfdt 'ABCDfF bbddff h' bs txt;
txt
ABCDfF bbddff h
create table t2 ( a char(10));
garbage;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1
...
...
mysql-test/suite/rpl/t/rpl_sp.test
View file @
fece177f
...
...
@@ -614,7 +614,7 @@ show function status like '%mysqltestbug36570%';
connection
master
;
flush
logs
;
let
$MYSQLD_DATADIR
=
`select @@datadir`
;
--
replace_regex
s
/
$MYSQL_TEST_DIR
/
MYSQL_TEST_DIR
/
s
/
TIMESTAMP
=
[
0
-
9
]
*/
TIMESTAMP
=
t
/
--
replace_regex
/
$MYSQL_TEST_DIR
/
MYSQL_TEST_DIR
/
/
TIMESTAMP
=
[
0
-
9
]
*/
TIMESTAMP
=
t
/
--
exec
$MYSQL_BINLOG
--
short
-
form
$MYSQLD_DATADIR
/
master
-
bin
.
000001
use
test
;
drop
procedure
mysqltestbug36570_p1
;
...
...
mysql-test/suite/sys_vars/t/report_port_basic.test
View file @
fece177f
...
...
@@ -2,7 +2,7 @@
#
# only global
#
--
replace_regex
s
/
[
0
-
9
]
+/
DEFAULT_MASTER_PORT
/
--
replace_regex
/
[
0
-
9
]
+/
DEFAULT_MASTER_PORT
/
select
@@
global
.
report_port
;
--
error
ER_INCORRECT_GLOBAL_LOCAL_VAR
select
@@
session
.
report_port
;
...
...
mysql-test/t/mysqltest.test
View file @
fece177f
...
...
@@ -2053,7 +2053,7 @@ select "at" as col1, "AT" as col2, "c" as col3;
--
replace_regex
/
a
/
b
/
/
ct
/
d
/
select
"a"
as
col1
,
"ct"
as
col2
;
--
replace_regex
/
(
strawberry
)
/
raspberry
and
\
1
/
/
blueberry
/
blackberry
/
/
potato
/
tomato
/
;
--
replace_regex
/
(
strawberry
)
/
raspberry
and
\
1
/
/
blueberry
/
blackberry
/
/
potato
/
tomato
/
select
"strawberry"
,
"blueberry"
,
"potato"
;
--
error
1
...
...
@@ -2098,6 +2098,12 @@ select "a is a and less is more" as txt;
select
"a is a and less is more"
as
txt
;
--
enable_query_log
#
# different delimiters
#
--
replace_regex
(
a
)[
b
]
/
c
/
d
/
<
e
>
{
f
}
i
{
g
\
/
\
}}
/
h
/
select
'ABCDEF abcdef g/}'
as
txt
;
#-------------------------------------------------------------------------
# BUG #11754855 : Passing variable to --error
#-------------------------------------------------------------------------
...
...
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