From e7ffc21546b68c22c6dbc80e2dc198039177c655 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jan 2003 14:48:58 +0400 Subject: Make the CLI client (client/mysql.cc) work with multi-line SPs. Make the mysqltest program (client/mysqltest.c) work with multi-line SPs. client/mysql.cc: Added 'delimiter' command client/mysqltest.c: Added 'delimiter' command mysql-test/install_test_db.sh: Fix for install 'proc' table mysql-test/r/connect.result: Fix for 'proc' table BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- client/mysql.cc | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'client/mysql.cc') diff --git a/client/mysql.cc b/client/mysql.cc index 58aee617107..2f8f2b821b7 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -100,6 +100,7 @@ extern "C" { #include "completion_hash.h" #define PROMPT_CHAR '\\' +#define DEFAULT_DELIMITER ';' typedef struct st_status { @@ -151,6 +152,7 @@ static char pager[FN_REFLEN], outfile[FN_REFLEN]; static FILE *PAGER, *OUTFILE; static MEM_ROOT hash_mem_root; static uint prompt_counter; +static char delimiter= DEFAULT_DELIMITER; #ifdef HAVE_SMEM static char *shared_memory_base_name=0; @@ -177,7 +179,7 @@ static int com_quit(String *str,char*), com_use(String *str,char*), com_source(String *str, char*), com_rehash(String *str, char*), com_tee(String *str, char*), com_notee(String *str, char*), com_shell(String *str, char *), - com_prompt(String *str, char*); + com_prompt(String *str, char*), com_delimiter(String *str, char*); #ifndef __WIN__ static int com_nopager(String *str, char*), com_pager(String *str, char*), @@ -245,7 +247,8 @@ static COMMANDS commands[] = { "Set outfile [to_outfile]. Append everything into given outfile." }, { "use", 'u', com_use, 1, "Use another database. Takes database name as argument." }, - + { "delimiter", 'd', com_delimiter, 1, + "Set query delimiter. " }, /* Get bash-like expansion for some commands */ { "create table", 0, 0, 0, ""}, { "create database", 0, 0, 0, ""}, @@ -911,7 +914,7 @@ static COMMANDS *find_command (char *name,char cmd_char) { while (my_isspace(system_charset_info,*name)) name++; - if (strchr(name,';') || strstr(name,"\\g")) + if (strchr(name, delimiter) || strstr(name,"\\g")) return ((COMMANDS *) 0); if ((end=strcont(name," \t"))) { @@ -989,7 +992,7 @@ static bool add_line(String &buffer,char *line,char *in_string, return 1; // Quit if (com->takes_params) { - for (pos++ ; *pos && *pos != ';' ; pos++) ; // Remove parameters + for (pos++ ; *pos && *pos != delimiter; pos++) ; // Remove parameters if (!*pos) pos--; } @@ -1005,7 +1008,7 @@ static bool add_line(String &buffer,char *line,char *in_string, continue; } } - else if (!*ml_comment && inchar == ';' && !*in_string) + else if (!*ml_comment && inchar == delimiter && !*in_string) { // ';' is end of command if (out != line) buffer.append(line,(uint) (out-line)); // Add this line @@ -1514,7 +1517,7 @@ com_help (String *buffer __attribute__((unused)), for (i = 0; commands[i].name; i++) { if (commands[i].func) - tee_fprintf(stdout, "%s\t(\\%c)\t%s\n", commands[i].name, + tee_fprintf(stdout, "%-10s(\\%c)\t%s\n", commands[i].name, commands[i].cmd_char, commands[i].doc); } if (connected) @@ -2324,6 +2327,37 @@ static int com_source(String *buffer, char *line) return error; } + /* ARGSUSED */ +static int +com_delimiter(String *buffer __attribute__((unused)), char *line) +{ + char *tmp; + char buff[256]; + + if (strlen(line)> 255) + { + put_info("'DELIMITER' command was too long.", INFO_ERROR); + return 0; + } + bzero(buff, sizeof(buff)); + strmov(buff, line); + tmp= get_arg(buff, 0); + + if (!tmp || !*tmp) + { + put_info("DELIMITER must be followed by a 'delimiter' char", INFO_ERROR); + return 0; + } + + if (strlen(tmp)> 1) + { + put_info("Argument must be one char", INFO_ERROR); + return 0; + } + + delimiter= *tmp; + return 0; +} /* ARGSUSED */ static int -- cgit v1.2.1