Commit 909c04a7 authored by unknown's avatar unknown

Added multi command support for mysql client.

parent f25cbdd9
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
const char *VER= "14.2"; const char *VER= "14.3";
/* Don't try to make a nice table if the data is too big */ /* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024 #define MAX_COLUMN_LENGTH 1024
...@@ -1665,79 +1665,82 @@ com_go(String *buffer,char *line __attribute__((unused))) ...@@ -1665,79 +1665,82 @@ com_go(String *buffer,char *line __attribute__((unused)))
buffer->length(0); // Remove query on error buffer->length(0); // Remove query on error
return error; return error;
} }
error=0; error=0;
buffer->length(0); buffer->length(0);
if (quick) do
{
if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql))
return put_error(&mysql);
}
else
{
error= mysql_store_result_for_lazy(&result);
if (error)
return error;
}
if (verbose >= 3 || !opt_silent)
mysql_end_timer(timer,time_buff);
else
time_buff[0]=0;
if (result)
{ {
if (!mysql_num_rows(result) && ! quick) if (quick)
{ {
strmov(buff, "Empty set"); if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql))
return put_error(&mysql);
} }
else else
{ {
init_pager(); error= mysql_store_result_for_lazy(&result);
if (opt_html) if (error)
print_table_data_html(result); return error;
else if (opt_xml) }
print_table_data_xml(result);
else if (vertical) if (verbose >= 3 || !opt_silent)
print_table_data_vertically(result); mysql_end_timer(timer,time_buff);
else if (opt_silent && verbose <= 2 && !output_tables) else
print_tab_data(result); time_buff[0]=0;
if (result)
{
if (!mysql_num_rows(result) && ! quick)
{
strmov(buff, "Empty set");
}
else else
print_table_data(result); {
sprintf(buff,"%ld %s in set", init_pager();
(long) mysql_num_rows(result), if (opt_html)
(long) mysql_num_rows(result) == 1 ? "row" : "rows"); print_table_data_html(result);
end_pager(); else if (opt_xml)
print_table_data_xml(result);
else if (vertical)
print_table_data_vertically(result);
else if (opt_silent && verbose <= 2 && !output_tables)
print_tab_data(result);
else
print_table_data(result);
sprintf(buff,"%ld %s in set",
(long) mysql_num_rows(result),
(long) mysql_num_rows(result) == 1 ? "row" : "rows");
end_pager();
}
} }
} else if (mysql_affected_rows(&mysql) == ~(ulonglong) 0)
else if (mysql_affected_rows(&mysql) == ~(ulonglong) 0) strmov(buff,"Query OK");
strmov(buff,"Query OK"); else
else sprintf(buff,"Query OK, %ld %s affected",
sprintf(buff,"Query OK, %ld %s affected", (long) mysql_affected_rows(&mysql),
(long) mysql_affected_rows(&mysql), (long) mysql_affected_rows(&mysql) == 1 ? "row" : "rows");
(long) mysql_affected_rows(&mysql) == 1 ? "row" : "rows");
pos=strend(buff);
pos=strend(buff); if ((warnings= mysql_warning_count(&mysql)))
if ((warnings= mysql_warning_count(&mysql))) {
{ *pos++= ',';
*pos++= ','; *pos++= ' ';
*pos++= ' '; pos=int2str(warnings, pos, 10);
pos=int2str(warnings, pos, 10); pos=strmov(pos, " warning");
pos=strmov(pos, " warning"); if (warnings != 1)
if (warnings != 1) *pos++= 's';
*pos++= 's'; }
} strmov(pos, time_buff);
strmov(pos, time_buff); put_info(buff,INFO_RESULT);
put_info(buff,INFO_RESULT); if (mysql_info(&mysql))
if (mysql_info(&mysql)) put_info(mysql_info(&mysql),INFO_RESULT);
put_info(mysql_info(&mysql),INFO_RESULT); put_info("",INFO_RESULT); // Empty row
put_info("",INFO_RESULT); // Empty row
if (result && !mysql_eof(result)) /* Something wrong when using quick */
if (result && !mysql_eof(result)) /* Something wrong when using quick */ error= put_error(&mysql);
error= put_error(&mysql); else if (unbuffered)
else if (unbuffered) fflush(stdout);
fflush(stdout); mysql_free_result(result);
mysql_free_result(result); } while (!mysql_next_result(&mysql));
return error; /* New command follows */ return error; /* New command follows */
} }
...@@ -2416,6 +2419,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line) ...@@ -2416,6 +2419,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line)
} }
strmake(delimiter, tmp, sizeof(delimiter) - 1); strmake(delimiter, tmp, sizeof(delimiter) - 1);
delimiter_length= strlen(delimiter); delimiter_length= strlen(delimiter);
delimiter_str= delimiter;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment