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
075d6954
Commit
075d6954
authored
Apr 04, 2007
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add expansion of $variables in "let from query",
"if with query" and "while with query"
parent
72098c7f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
+26
-3
client/mysqltest.c
client/mysqltest.c
+8
-3
mysql-test/r/mysqltest.result
mysql-test/r/mysqltest.result
+3
-0
mysql-test/t/mysqltest.test
mysql-test/t/mysqltest.test
+15
-0
No files found.
client/mysqltest.c
View file @
075d6954
...
@@ -1328,6 +1328,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
...
@@ -1328,6 +1328,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
MYSQL_RES
*
res
;
MYSQL_RES
*
res
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
MYSQL
*
mysql
=
&
cur_con
->
mysql
;
MYSQL
*
mysql
=
&
cur_con
->
mysql
;
DYNAMIC_STRING
ds_query
;
DBUG_ENTER
(
"var_query_set"
);
DBUG_ENTER
(
"var_query_set"
);
LINT_INIT
(
res
);
LINT_INIT
(
res
);
...
@@ -1337,13 +1338,17 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
...
@@ -1337,13 +1338,17 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
die
(
"Syntax error in query, missing '`'"
);
die
(
"Syntax error in query, missing '`'"
);
++
query
;
++
query
;
if
(
mysql_real_query
(
mysql
,
query
,
(
int
)(
end
-
query
))
||
/* Eval the query, thus replacing all environment variables */
init_dynamic_string
(
&
ds_query
,
0
,
(
end
-
query
)
+
32
,
256
);
do_eval
(
&
ds_query
,
query
,
end
,
FALSE
);
if
(
mysql_real_query
(
mysql
,
ds_query
.
str
,
ds_query
.
length
)
||
!
(
res
=
mysql_store_result
(
mysql
)))
!
(
res
=
mysql_store_result
(
mysql
)))
{
{
*
end
=
0
;
die
(
"Error running query '%s': %d %s"
,
ds_query
.
str
,
die
(
"Error running query '%s': %d %s"
,
query
,
mysql_errno
(
mysql
),
mysql_error
(
mysql
));
mysql_errno
(
mysql
),
mysql_error
(
mysql
));
}
}
dynstr_free
(
&
ds_query
);
if
((
row
=
mysql_fetch_row
(
res
))
&&
row
[
0
])
if
((
row
=
mysql_fetch_row
(
res
))
&&
row
[
0
])
{
{
...
...
mysql-test/r/mysqltest.result
View file @
075d6954
...
@@ -268,6 +268,9 @@ mysqltest: At line 1: Missing assignment operator in let
...
@@ -268,6 +268,9 @@ mysqltest: At line 1: Missing assignment operator in let
1
1
# Execute: echo $success ;
# Execute: echo $success ;
1
1
var2: content of variable 1
var3: content of variable 1 content of variable 1
length of var3 is longer than 0
mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Could not open file ./non_existingFile
mysqltest: At line 1: Could not open file ./non_existingFile
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep
...
...
mysql-test/t/mysqltest.test
View file @
075d6954
...
@@ -685,6 +685,21 @@ echo # <whatever> success: $success ;
...
@@ -685,6 +685,21 @@ echo # <whatever> success: $success ;
--
echo
# Execute: echo \$success ;
--
echo
# Execute: echo \$success ;
echo
$success
;
echo
$success
;
# ----------------------------------------------------------------------------
# Test let from query with $variable
# let $<var_name>=`<query with $variable>`;
# ----------------------------------------------------------------------------
let
$var1
=
content
of
variable
1
;
let
$var2
=
`select "$var1"`
;
let
$var3
=
`select concat("$var1", " ", "$var2")`
;
echo
var2
:
$var2
;
echo
var3
:
$var3
;
if
(
`select length("$var3") > 0`
)
{
echo
length
of
var3
is
longer
than
0
;
}
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Test to assign let from query
# Test to assign let from query
# let $<var_name>=`<query>`;
# let $<var_name>=`<query>`;
...
...
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