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
6978a518
Commit
6978a518
authored
May 03, 2006
by
jimw@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal:/home/bk/mysql-5.1-new
into mysql.com:/home/jimw/my/mysql-5.1-clean
parents
9d4a065f
da9a1166
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
6 deletions
+52
-6
client/mysql.cc
client/mysql.cc
+52
-6
No files found.
client/mysql.cc
View file @
6978a518
...
...
@@ -136,7 +136,7 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
tty_password
=
0
,
opt_nobeep
=
0
,
opt_reconnect
=
1
,
default_charset_used
=
0
,
opt_secure_auth
=
0
,
default_pager_set
=
0
,
opt_sigint_ignore
=
0
,
show_warnings
=
0
;
show_warnings
=
0
,
executing_query
=
0
,
interrupted_query
=
0
;
static
ulong
opt_max_allowed_packet
,
opt_net_buffer_length
;
static
uint
verbose
=
0
,
opt_silent
=
0
,
opt_mysql_port
=
0
,
opt_local_infile
=
0
;
static
my_string
opt_mysql_unix_port
=
0
;
...
...
@@ -338,7 +338,7 @@ static void end_timer(ulong start_time,char *buff);
static
void
mysql_end_timer
(
ulong
start_time
,
char
*
buff
);
static
void
nice_time
(
double
sec
,
char
*
buff
,
bool
part_second
);
static
sig_handler
mysql_end
(
int
sig
);
static
sig_handler
handle_sigint
(
int
sig
);
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -420,7 +420,7 @@ int main(int argc,char *argv[])
if
(
opt_sigint_ignore
)
signal
(
SIGINT
,
SIG_IGN
);
else
signal
(
SIGINT
,
mysql_end
);
// Catch SIGINT to clean up
signal
(
SIGINT
,
handle_sigint
);
// Catch SIGINT to clean up
signal
(
SIGQUIT
,
mysql_end
);
// Catch SIGQUIT to clean up
/*
...
...
@@ -523,6 +523,35 @@ sig_handler mysql_end(int sig)
}
/*
This function handles sigint calls
If query is in process, kill query
no query in process, terminate like previous behavior
*/
sig_handler
handle_sigint
(
int
sig
)
{
char
kill_buffer
[
40
];
MYSQL
*
kill_mysql
=
NULL
;
/* terminate if no query being executed, or we already tried interrupting */
if
(
!
executing_query
||
interrupted_query
)
mysql_end
(
sig
);
kill_mysql
=
mysql_init
(
kill_mysql
);
if
(
!
mysql_real_connect
(
kill_mysql
,
current_host
,
current_user
,
opt_password
,
""
,
opt_mysql_port
,
opt_mysql_unix_port
,
0
))
mysql_end
(
sig
);
/* kill_buffer is always big enough because max length of %lu is 15 */
sprintf
(
kill_buffer
,
"KILL /*!50000 QUERY */ %lu"
,
mysql_thread_id
(
&
mysql
));
mysql_real_query
(
kill_mysql
,
kill_buffer
,
strlen
(
kill_buffer
));
mysql_close
(
kill_mysql
);
tee_fprintf
(
stdout
,
"Query aborted by Ctrl+C
\n
"
);
interrupted_query
=
1
;
}
static
struct
my_option
my_long_options
[]
=
{
{
"help"
,
'?'
,
"Display this help and exit."
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
...
...
@@ -1932,6 +1961,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
uint
error
=
0
;
int
err
=
0
;
interrupted_query
=
0
;
if
(
!
status
.
batch
)
{
old_buffer
=
*
buffer
;
// Save for edit command
...
...
@@ -1967,7 +1997,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
}
timer
=
start_timer
();
executing_query
=
1
;
error
=
mysql_real_query_for_lazy
(
buffer
->
ptr
(),
buffer
->
length
());
#ifdef HAVE_READLINE
...
...
@@ -1981,6 +2011,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
if
(
error
)
{
executing_query
=
0
;
buffer
->
length
(
0
);
// Remove query on error
return
error
;
}
...
...
@@ -1992,13 +2023,19 @@ com_go(String *buffer,char *line __attribute__((unused)))
if
(
quick
)
{
if
(
!
(
result
=
mysql_use_result
(
&
mysql
))
&&
mysql_field_count
(
&
mysql
))
return
put_error
(
&
mysql
);
{
executing_query
=
0
;
return
put_error
(
&
mysql
);
}
}
else
{
error
=
mysql_store_result_for_lazy
(
&
result
);
if
(
error
)
return
error
;
{
executing_query
=
0
;
return
error
;
}
}
if
(
verbose
>=
3
||
!
opt_silent
)
...
...
@@ -2073,6 +2110,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
(
mysql
.
server_status
&
SERVER_STATUS_DB_DROPPED
))
get_current_db
();
executing_query
=
0
;
return
error
;
/* New command follows */
}
...
...
@@ -2286,6 +2324,8 @@ print_table_data(MYSQL_RES *result)
while
((
cur
=
mysql_fetch_row
(
result
)))
{
if
(
interrupted_query
)
break
;
ulong
*
lengths
=
mysql_fetch_lengths
(
result
);
(
void
)
tee_fputs
(
"| "
,
PAGER
);
mysql_field_seek
(
result
,
0
);
...
...
@@ -2393,6 +2433,8 @@ print_table_data_html(MYSQL_RES *result)
}
while
((
cur
=
mysql_fetch_row
(
result
)))
{
if
(
interrupted_query
)
break
;
ulong
*
lengths
=
mysql_fetch_lengths
(
result
);
(
void
)
tee_fputs
(
"<TR>"
,
PAGER
);
for
(
uint
i
=
0
;
i
<
mysql_num_fields
(
result
);
i
++
)
...
...
@@ -2422,6 +2464,8 @@ print_table_data_xml(MYSQL_RES *result)
fields
=
mysql_fetch_fields
(
result
);
while
((
cur
=
mysql_fetch_row
(
result
)))
{
if
(
interrupted_query
)
break
;
ulong
*
lengths
=
mysql_fetch_lengths
(
result
);
(
void
)
tee_fputs
(
"
\n
<row>
\n
"
,
PAGER
);
for
(
uint
i
=
0
;
i
<
mysql_num_fields
(
result
);
i
++
)
...
...
@@ -2456,6 +2500,8 @@ print_table_data_vertically(MYSQL_RES *result)
mysql_field_seek
(
result
,
0
);
for
(
uint
row_count
=
1
;
(
cur
=
mysql_fetch_row
(
result
));
row_count
++
)
{
if
(
interrupted_query
)
break
;
mysql_field_seek
(
result
,
0
);
tee_fprintf
(
PAGER
,
"*************************** %d. row ***************************
\n
"
,
row_count
);
...
...
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