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
a7b0312c
Commit
a7b0312c
authored
Oct 29, 2008
by
Mats Kindahl
Browse files
Options
Browse Files
Download
Plain Diff
Merging with 5.1-rpl
parents
533cf795
39987388
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
45 deletions
+74
-45
client/mysqltest.cc
client/mysqltest.cc
+45
-45
mysql-test/r/mysqltest.result
mysql-test/r/mysqltest.result
+5
-0
mysql-test/t/mysqltest.test
mysql-test/t/mysqltest.test
+24
-0
No files found.
client/mysqltest.cc
View file @
a7b0312c
...
...
@@ -2035,17 +2035,6 @@ void var_set_errno(int sql_errno)
}
/*
Update $mysql_get_server_version variable with version
of the currently connected server
*/
void
var_set_mysql_get_server_version
(
MYSQL
*
mysql
)
{
var_set_int
(
"$mysql_get_server_version"
,
mysql_get_server_version
(
mysql
));
}
/*
Set variable from the result of a query
...
...
@@ -4461,36 +4450,51 @@ void set_reconnect(MYSQL* mysql, int val)
}
int
select_connection_name
(
const
char
*
name
)
/**
Change the current connection to the given st_connection, and update
$mysql_get_server_version and $CURRENT_CONNECTION accordingly.
*/
void
set_current_connection
(
struct
st_connection
*
con
)
{
cur_con
=
con
;
/* Update $mysql_get_server_version to that of current connection */
var_set_int
(
"$mysql_get_server_version"
,
mysql_get_server_version
(
&
con
->
mysql
));
/* Update $CURRENT_CONNECTION to the name of the current connection */
var_set_string
(
"$CURRENT_CONNECTION"
,
con
->
name
);
}
void
select_connection_name
(
const
char
*
name
)
{
DBUG_ENTER
(
"select_connection_name"
);
DBUG_PRINT
(
"enter"
,(
"name: '%s'"
,
name
));
st_connection
*
con
=
find_connection_by_name
(
name
);
if
(
!
(
cur_con
=
find_connection_by_name
(
name
))
)
if
(
!
con
)
die
(
"connection '%s' not found in connection pool"
,
name
);
/* Update $mysql_get_server_version to that of current connection */
var_set_mysql_get_server_version
(
&
cur_con
->
mysql
);
set_current_connection
(
con
);
DBUG_
RETURN
(
0
)
;
DBUG_
VOID_RETURN
;
}
int
select_connection
(
struct
st_command
*
command
)
void
select_connection
(
struct
st_command
*
command
)
{
char
*
name
;
char
*
p
=
command
->
first_argument
;
DBUG_ENTER
(
"select_connection"
);
static
DYNAMIC_STRING
ds_connection
;
const
struct
command_arg
connection_args
[]
=
{
{
"connection_name"
,
ARG_STRING
,
TRUE
,
&
ds_connection
,
"Name of the connection that we switch to."
}
};
check_command_args
(
command
,
command
->
first_argument
,
connection_args
,
sizeof
(
connection_args
)
/
sizeof
(
struct
command_arg
),
','
);
if
(
!*
p
)
die
(
"Missing connection name in connect"
);
name
=
p
;
while
(
*
p
&&
!
my_isspace
(
charset_info
,
*
p
))
p
++
;
if
(
*
p
)
*
p
++=
0
;
command
->
last_argument
=
p
;
DBUG_RETURN
(
select_connection_name
(
name
));
DBUG_PRINT
(
"info"
,
(
"changing connection: %s"
,
ds_connection
.
str
));
select_connection_name
(
ds_connection
.
str
);
dynstr_free
(
&
ds_connection
);
DBUG_VOID_RETURN
;
}
...
...
@@ -4898,15 +4902,12 @@ void do_connect(struct st_command *command)
if
(
!
(
con_slot
->
name
=
my_strdup
(
ds_connection_name
.
str
,
MYF
(
MY_WME
))))
die
(
"Out of memory"
);
con_slot
->
name_len
=
strlen
(
con_slot
->
name
);
cur_con
=
con_slot
;
set_current_connection
(
con_slot
)
;
if
(
con_slot
==
next_con
)
next_con
++
;
/* if we used the next_con slot, advance the pointer */
}
/* Update $mysql_get_server_version to that of current connection */
var_set_mysql_get_server_version
(
&
cur_con
->
mysql
);
dynstr_free
(
&
ds_connection_name
);
dynstr_free
(
&
ds_host
);
dynstr_free
(
&
ds_user
);
...
...
@@ -7478,37 +7479,37 @@ int main(int argc, char **argv)
if
(
cursor_protocol_enabled
)
ps_protocol_enabled
=
1
;
cur_
con
=
connections
;
if
(
!
(
mysql_init
(
&
c
ur_c
on
->
mysql
)))
st_connection
*
con
=
connections
;
if
(
!
(
mysql_init
(
&
con
->
mysql
)))
die
(
"Failed in mysql_init()"
);
if
(
opt_compress
)
mysql_options
(
&
c
ur_c
on
->
mysql
,
MYSQL_OPT_COMPRESS
,
NullS
);
mysql_options
(
&
c
ur_c
on
->
mysql
,
MYSQL_OPT_LOCAL_INFILE
,
0
);
mysql_options
(
&
c
ur_c
on
->
mysql
,
MYSQL_SET_CHARSET_NAME
,
mysql_options
(
&
con
->
mysql
,
MYSQL_OPT_COMPRESS
,
NullS
);
mysql_options
(
&
con
->
mysql
,
MYSQL_OPT_LOCAL_INFILE
,
0
);
mysql_options
(
&
con
->
mysql
,
MYSQL_SET_CHARSET_NAME
,
charset_info
->
csname
);
if
(
opt_charsets_dir
)
mysql_options
(
&
c
ur_c
on
->
mysql
,
MYSQL_SET_CHARSET_DIR
,
mysql_options
(
&
con
->
mysql
,
MYSQL_SET_CHARSET_DIR
,
opt_charsets_dir
);
#ifdef HAVE_OPENSSL
if
(
opt_use_ssl
)
{
mysql_ssl_set
(
&
c
ur_c
on
->
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
mysql_ssl_set
(
&
con
->
mysql
,
opt_ssl_key
,
opt_ssl_cert
,
opt_ssl_ca
,
opt_ssl_capath
,
opt_ssl_cipher
);
#if MYSQL_VERSION_ID >= 50000
/* Turn on ssl_verify_server_cert only if host is "localhost" */
opt_ssl_verify_server_cert
=
opt_host
&&
!
strcmp
(
opt_host
,
"localhost"
);
mysql_options
(
&
c
ur_c
on
->
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
mysql_options
(
&
con
->
mysql
,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
,
&
opt_ssl_verify_server_cert
);
#endif
}
#endif
if
(
!
(
c
ur_c
on
->
name
=
my_strdup
(
"default"
,
MYF
(
MY_WME
))))
if
(
!
(
con
->
name
=
my_strdup
(
"default"
,
MYF
(
MY_WME
))))
die
(
"Out of memory"
);
safe_connect
(
&
c
ur_con
->
mysql
,
cur_
con
->
name
,
opt_host
,
opt_user
,
opt_pass
,
safe_connect
(
&
c
on
->
mysql
,
con
->
name
,
opt_host
,
opt_user
,
opt_pass
,
opt_db
,
opt_port
,
unix_sock
);
/* Use all time until exit if no explicit 'start_timer' */
...
...
@@ -7521,8 +7522,7 @@ int main(int argc, char **argv)
*/
var_set_errno
(
-
1
);
/* Update $mysql_get_server_version to that of current connection */
var_set_mysql_get_server_version
(
&
cur_con
->
mysql
);
set_current_connection
(
con
);
if
(
opt_include
)
{
...
...
mysql-test/r/mysqltest.result
View file @
a7b0312c
...
...
@@ -740,4 +740,9 @@ select 1;
1
-- a comment for the server;
mysqltest: At line 1: Found line beginning with -- that didn't contain a valid mysqltest command, check your syntax or use # if you intended to write a comment
con1
default
con1
default
con1
End of tests
mysql-test/t/mysqltest.test
View file @
a7b0312c
...
...
@@ -2183,5 +2183,29 @@ select 1;
--
exec
echo
"--select 1;"
|
$MYSQL_TEST
2
>&
1
# ----------------------------------------------------------------------------
# BUG#35701: please allow test language variables in connection and sync_slave_with_master
# Test that "connection $variable" works and that $CURRENT_CONNECTION has the right value.
# ----------------------------------------------------------------------------
connect
(
con1
,
localhost
,
root
,,);
--
echo
$CURRENT_CONNECTION
connection
default
;
--
echo
$CURRENT_CONNECTION
connection
con1
;
--
echo
$CURRENT_CONNECTION
let
$x
=
default
;
let
$y
=
con1
;
connection
$x
;
--
echo
$CURRENT_CONNECTION
connection
$y
;
--
echo
$CURRENT_CONNECTION
--
echo
End
of
tests
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