summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-08-22 01:46:36 +0300
committerunknown <monty@hundin.mysql.fi>2001-08-22 01:46:36 +0300
commitd85006f2549dd708e356a645192bbdd838aee5fb (patch)
tree1f4c3bbe9f7fc5c91dd4d0cdce426593b20666dd /client
parent001f7fb5d379dcd38d2d861529301838a6d11e22 (diff)
parent31b9e6e03f8fe4be1816c3f33aaefb9a931dcef3 (diff)
downloadmariadb-git-d85006f2549dd708e356a645192bbdd838aee5fb.tar.gz
Merge work:/home/bk/mysql into hundin.mysql.fi:/my/bk/mysql
Docs/manual.texi: Auto merged
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc38
-rw-r--r--client/mysqladmin.c12
-rw-r--r--client/mysqlbinlog.cc2
-rw-r--r--client/mysqldump.c84
-rw-r--r--client/mysqlimport.c13
-rw-r--r--client/mysqltest.c36
6 files changed, 112 insertions, 73 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 8d926a54840..e4db7e93256 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -77,7 +77,7 @@ extern "C" {
#undef bcmp // Fix problem with new readline
#undef bzero
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
#include <conio.h>
#else
#include <readline/readline.h>
@@ -569,7 +569,7 @@ static int get_options(int argc, char **argv)
set_all_changeable_vars(changeable_vars);
while ((c=getopt_long(argc,argv,
- "?ABCD:LfgGHinNoqrstTU::vVw::WEe:h:O:P:S:u:#::p::",
+ (char*) "?ABCD:LfgGHinNoqrstTU::vVw::WEe:h:O:P:S:u:#::p::",
long_options, &option_index)) != EOF)
{
switch(c) {
@@ -767,10 +767,20 @@ static int get_options(int argc, char **argv)
return(0);
}
+#if defined(OS2)
+static char* readline( char* prompt)
+{
+#if defined(OS2)
+ static char linebuffer[254];
+#endif
+ puts( prompt);
+ return gets( linebuffer);
+}
+#endif
static int read_lines(bool execute_commands)
{
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
char linebuffer[254];
#endif
char *line;
@@ -790,7 +800,7 @@ static int read_lines(bool execute_commands)
}
else
{
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
if (opt_outfile && glob_buffer.is_empty())
fflush(OUTFILE);
tee_fputs(glob_buffer.is_empty() ? "mysql> " :
@@ -1483,7 +1493,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
static void init_pager()
{
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined( OS2)
if (!opt_nopager)
{
if (!(PAGER= popen(pager, "w")))
@@ -1499,7 +1509,7 @@ static void init_pager()
static void end_pager()
{
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined( OS2)
if (!opt_nopager)
pclose(PAGER);
#endif
@@ -2337,6 +2347,9 @@ void tee_fprintf(FILE *file, const char *fmt, ...)
va_start(args, fmt);
(void) vfprintf(file, fmt, args);
+#ifdef OS2
+ fflush( file);
+#endif
if (opt_outfile)
(void) vfprintf(OUTFILE, fmt, args);
va_end(args);
@@ -2346,6 +2359,9 @@ void tee_fprintf(FILE *file, const char *fmt, ...)
void tee_fputs(const char *s, FILE *file)
{
fputs(s, file);
+#ifdef OS2
+ fflush( file);
+#endif
if (opt_outfile)
fputs(s, OUTFILE);
}
@@ -2355,6 +2371,9 @@ void tee_puts(const char *s, FILE *file)
{
fputs(s, file);
fputs("\n", file);
+#ifdef OS2
+ fflush( file);
+#endif
if (opt_outfile)
{
fputs(s, OUTFILE);
@@ -2365,11 +2384,14 @@ void tee_puts(const char *s, FILE *file)
void tee_putc(int c, FILE *file)
{
putc(c, file);
+#ifdef OS2
+ fflush( file);
+#endif
if (opt_outfile)
putc(c, OUTFILE);
}
-#ifdef __WIN__
+#if defined( __WIN__) || defined( OS2)
#include <time.h>
#else
#include <sys/times.h>
@@ -2379,7 +2401,7 @@ void tee_putc(int c, FILE *file)
static ulong start_timer(void)
{
-#ifdef __WIN__
+#if defined( __WIN__) || defined( OS2)
return clock();
#else
struct tms tms_tmp;
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index 3570cefc4ae..e95d6492949 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -132,7 +132,7 @@ static struct option long_options[] = {
{0, 0, 0, 0}
};
-CHANGEABLE_VAR changeable_vars[] = {
+static CHANGEABLE_VAR changeable_vars[] = {
{ "connect_timeout", (long*) &opt_connect_timeout, 0, 0, 3600*12, 0, 1},
{ "shutdown_timeout", (long*) &opt_shutdown_timeout, SHUTDOWN_DEF_TIMEOUT, 0,
3600*12, 0, 1},
@@ -152,7 +152,8 @@ int main(int argc,char *argv[])
load_defaults("my",load_default_groups,&argc,&argv);
set_all_changeable_vars( changeable_vars );
- while ((c=getopt_long(argc,argv,"h:i:p::u:#::P:sS:Ct:fq?vVw::WrEO:",
+ while ((c=getopt_long(argc,argv,
+ (char*) "h:i:p::u:#::P:sS:Ct:fq?vVw::WrEO:",
long_options, &option_index)) != EOF)
{
switch(c) {
@@ -1121,14 +1122,15 @@ static void wait_pidfile(char *pidfile)
uint count=0;
system_filename(buff,pidfile);
- while ((fd = open(buff, O_RDONLY)) >= 0 && count++ < opt_shutdown_timeout)
+ while ((fd = my_open(buff, O_RDONLY, MYF(0))) >= 0 &&
+ count++ < opt_shutdown_timeout)
{
- close(fd);
+ my_close(fd,MYF(0));
sleep(1);
}
if (fd >= 0)
{
- close(fd);
+ my_close(fd,MYF(0));
fprintf(stderr,
"Warning; Aborted waiting on pid file: '%s' after %d seconds\n",
buff, count-1);
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 757e9dce810..f55a5a3f7c4 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -41,8 +41,6 @@ uint32 server_id = 0;
// needed by net_serv.c
ulong bytes_sent = 0L, bytes_received = 0L;
ulong mysqld_net_retry_count = 10L;
-ulong net_read_timeout= NET_READ_TIMEOUT;
-ulong net_write_timeout= NET_WRITE_TIMEOUT;
uint test_flags = 0;
FILE *result_file;
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 4893c13a0a0..29629940fb5 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -85,11 +85,11 @@ static int first_error=0;
extern ulong net_buffer_length;
static DYNAMIC_STRING extended_row;
#include "sslopt-vars.h"
-FILE *result_file;
+FILE *md_result_file;
-enum options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_KEYWORDS,
- OPT_LOCKS, OPT_DROP, OPT_OPTIMIZE, OPT_DELAYED, OPT_TABLES,
- OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
+enum md_options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
+ OPT_KEYWORDS, OPT_LOCKS, OPT_DROP, OPT_OPTIMIZE, OPT_DELAYED,
+ OPT_TABLES, MD_OPT_CHARSETS_DIR, MD_OPT_DEFAULT_CHARSET};
static struct option long_options[] =
{
@@ -98,12 +98,12 @@ static struct option long_options[] =
{"add-drop-table", no_argument, 0, OPT_DROP},
{"add-locks", no_argument, 0, OPT_LOCKS},
{"allow-keywords", no_argument, 0, OPT_KEYWORDS},
- {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR},
+ {"character-sets-dir",required_argument,0, MD_OPT_CHARSETS_DIR},
{"complete-insert", no_argument, 0, 'c'},
{"compress", no_argument, 0, 'C'},
{"databases", no_argument, 0, 'B'},
{"debug", optional_argument, 0, '#'},
- {"default-character-set", required_argument, 0, OPT_DEFAULT_CHARSET},
+ {"default-character-set", required_argument, 0, MD_OPT_DEFAULT_CHARSET},
{"delayed-insert", no_argument, 0, OPT_DELAYED},
{"extended-insert", no_argument, 0, 'e'},
{"fields-terminated-by", required_argument, 0, (int) OPT_FTB},
@@ -145,7 +145,7 @@ static struct option long_options[] =
static const char *load_default_groups[]= { "mysqldump","client",0 };
-CHANGEABLE_VAR changeable_vars[] = {
+CHANGEABLE_VAR md_changeable_vars[] = {
{ "max_allowed_packet", (long*) &max_allowed_packet,24*1024*1024,4096,
24*1024L*1024L,MALLOC_OVERHEAD,1024},
{ "net_buffer_length", (long*) &net_buffer_length,1024*1024L-1025,4096,
@@ -265,10 +265,10 @@ puts("\
print_defaults("my",load_default_groups);
printf("\nPossible variables for option --set-variable (-O) are:\n");
- for (i=0 ; changeable_vars[i].name ; i++)
+ for (i=0 ; md_changeable_vars[i].name ; i++)
printf("%-20s current value: %lu\n",
- changeable_vars[i].name,
- (ulong) *changeable_vars[i].varptr);
+ md_changeable_vars[i].name,
+ (ulong) *md_changeable_vars[i].varptr);
} /* usage */
@@ -290,9 +290,9 @@ static int get_options(int *argc,char ***argv)
int c,option_index;
my_bool tty_password=0;
- result_file=stdout;
+ md_result_file=stdout;
load_defaults("my",load_default_groups,argc,argv);
- set_all_changeable_vars(changeable_vars);
+ set_all_changeable_vars(md_changeable_vars);
while ((c=getopt_long(*argc,*argv,
"#::p::h:u:O:P:r:S:T:EBaAcCdefFlnqtvVw:?Ix",
long_options, &option_index)) != EOF)
@@ -307,10 +307,10 @@ static int get_options(int *argc,char ***argv)
case 'A':
opt_alldbs=1;
break;
- case OPT_DEFAULT_CHARSET:
+ case MD_OPT_DEFAULT_CHARSET:
default_charset= optarg;
break;
- case OPT_CHARSETS_DIR:
+ case MD_OPT_CHARSETS_DIR:
charsets_dir= optarg;
break;
case 'f':
@@ -332,7 +332,7 @@ static int get_options(int *argc,char ***argv)
break;
#endif
case 'O':
- if (set_changeable_var(optarg, changeable_vars))
+ if (set_changeable_var(optarg, md_changeable_vars))
{
usage();
return(1);
@@ -355,7 +355,7 @@ static int get_options(int *argc,char ***argv)
opt_mysql_port= (unsigned int) atoi(optarg);
break;
case 'r':
- if (!(result_file = my_fopen(optarg, O_WRONLY | O_BINARY,
+ if (!(md_result_file = my_fopen(optarg, O_WRONLY | O_BINARY,
MYF(MY_WME))))
exit(1);
break;
@@ -602,7 +602,7 @@ static uint getTableStructure(char *table, char* db)
char *strpos, *table_name;
const char *delayed;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN+3];
- FILE *sql_file = result_file;
+ FILE *sql_file = md_result_file;
DBUG_ENTER("getTableStructure");
delayed= opt_delayed ? " DELAYED " : "";
@@ -973,14 +973,14 @@ static void dumpTable(uint numFields, char *table)
}
else
{
- fprintf(result_file,"\n#\n# Dumping data for table '%s'\n", table);
+ fprintf(md_result_file,"\n#\n# Dumping data for table '%s'\n", table);
sprintf(query, "SELECT * FROM %s", quote_name(table,table_buff));
if (where)
{
- fprintf(result_file,"# WHERE: %s\n",where);
+ fprintf(md_result_file,"# WHERE: %s\n",where);
strxmov(strend(query), " WHERE ",where,NullS);
}
- fputs("#\n\n", result_file);
+ fputs("#\n\n", md_result_file);
if (mysql_query(sock, query))
{
@@ -1007,7 +1007,7 @@ static void dumpTable(uint numFields, char *table)
}
if (opt_lock)
- fprintf(result_file,"LOCK TABLES %s WRITE;\n",
+ fprintf(md_result_file,"LOCK TABLES %s WRITE;\n",
quote_name(table,table_buff));
total_length=net_buffer_length; /* Force row break */
@@ -1021,7 +1021,7 @@ static void dumpTable(uint numFields, char *table)
ulong *lengths=mysql_fetch_lengths(res);
rownr++;
if (!extended_insert)
- fputs(insert_pat,result_file);
+ fputs(insert_pat,md_result_file);
mysql_field_seek(res,0);
for (i = 0; i < mysql_num_fields(res); i++)
@@ -1075,17 +1075,17 @@ static void dumpTable(uint numFields, char *table)
else
{
if (i)
- fputc(',',result_file);
+ fputc(',',md_result_file);
if (row[i])
{
if (!IS_NUM_FIELD(field))
- unescape(result_file, row[i], lengths[i]);
+ unescape(md_result_file, row[i], lengths[i]);
else
- fputs(row[i],result_file);
+ fputs(row[i],md_result_file);
}
else
{
- fputs("NULL",result_file);
+ fputs("NULL",md_result_file);
}
}
}
@@ -1098,25 +1098,25 @@ static void dumpTable(uint numFields, char *table)
if (total_length + row_length < net_buffer_length)
{
total_length += row_length;
- fputc(',',result_file); /* Always row break */
- fputs(extended_row.str,result_file);
+ fputc(',',md_result_file); /* Always row break */
+ fputs(extended_row.str,md_result_file);
}
else
{
if (row_break)
- fputs(";\n", result_file);
+ fputs(";\n", md_result_file);
row_break=1; /* This is first row */
- fputs(insert_pat,result_file);
- fputs(extended_row.str,result_file);
+ fputs(insert_pat,md_result_file);
+ fputs(extended_row.str,md_result_file);
total_length = row_length+init_length;
}
}
else
- fputs(");\n", result_file);
+ fputs(");\n", md_result_file);
}
if (extended_insert && row_break)
- fputs(";\n", result_file); /* If not empty table */
- fflush(result_file);
+ fputs(";\n", md_result_file); /* If not empty table */
+ fflush(md_result_file);
if (mysql_errno(sock))
{
sprintf(query,"%s: Error %d: %s when dumping table '%s' at row: %ld\n",
@@ -1130,7 +1130,7 @@ static void dumpTable(uint numFields, char *table)
return;
}
if (opt_lock)
- fputs("UNLOCK TABLES;\n", result_file);
+ fputs("UNLOCK TABLES;\n", md_result_file);
mysql_free_result(res);
}
} /* dumpTable */
@@ -1206,11 +1206,11 @@ static int init_dumping(char *database)
{
if (opt_databases || opt_alldbs)
{
- fprintf(result_file,"\n#\n# Current Database: %s\n#\n", database);
+ fprintf(md_result_file,"\n#\n# Current Database: %s\n#\n", database);
if (!opt_create_db)
- fprintf(result_file,"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
+ fprintf(md_result_file,"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
database);
- fprintf(result_file,"\nUSE %s;\n", database);
+ fprintf(md_result_file,"\nUSE %s;\n", database);
}
}
if (extended_insert)
@@ -1342,7 +1342,7 @@ int main(int argc, char **argv)
if (dbConnect(current_host, current_user, opt_password))
exit(EX_MYSQLERR);
if (!path)
- write_heder(result_file, *argv);
+ write_heder(md_result_file, *argv);
if (opt_first_slave)
{
@@ -1378,9 +1378,9 @@ int main(int argc, char **argv)
}
}
dbDisconnect(current_host);
- fputs("\n", result_file);
- if (result_file != stdout)
- my_fclose(result_file, MYF(0));
+ fputs("\n", md_result_file);
+ if (md_result_file != stdout)
+ my_fclose(md_result_file, MYF(0));
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
if (extended_insert)
dynstr_free(&extended_row);
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 79f0a8d584e..cbdedf56cbe 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -41,7 +41,7 @@ static char *field_escape(char *to,const char *from,uint length);
static char *add_load_option(char *ptr,const char *object,
const char *statement);
-static my_bool verbose=0,lock_tables=0,ignore_errors=0,delete=0,
+static my_bool verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0,
replace=0,silent=0,ignore=0,opt_compress=0,opt_local_file=0;
static MYSQL mysql_connection;
@@ -54,8 +54,8 @@ static uint opt_mysql_port=0;
static my_string opt_mysql_unix_port=0;
#include "sslopt-vars.h"
-enum options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
- OPT_LOW_PRIORITY, OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
+enum mi_options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
+ OPT_LOW_PRIORITY, OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
static struct option long_options[] =
{
@@ -173,7 +173,8 @@ static int get_options(int *argc, char ***argv)
int c, option_index;
my_bool tty_password=0;
- while ((c=getopt_long(*argc,*argv,"#::p::c:h:u:P:S:CdfilLrsvV?IW",
+ while ((c=getopt_long(*argc,*argv,
+ (char*) "#::p::c:h:u:P:S:CdfilLrsvV?IW",
long_options, &option_index)) != EOF)
{
switch(c) {
@@ -190,7 +191,7 @@ static int get_options(int *argc, char ***argv)
charsets_dir= optarg;
break;
case 'd':
- delete= 1;
+ opt_delete= 1;
break;
case 'f':
ignore_errors= 1;
@@ -313,7 +314,7 @@ static int write_to_table(char *filename, MYSQL *sock)
else
my_load_path(hard_path, filename, NULL); /* filename includes the path */
- if (delete)
+ if (opt_delete)
{
if (verbose)
fprintf(stdout, "Deleting the old data from table %s\n", tablename);
diff --git a/client/mysqltest.c b/client/mysqltest.c
index f6d87352a6c..2d8c4e00416 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -51,7 +51,11 @@
#include <mysql.h>
#include <mysql_version.h>
#include <m_ctype.h>
-#include <my_config.h>
+#ifdef OS2
+#include <config-os2.h>
+#else
+ #include <my_config.h>
+#endif
#include <my_dir.h>
#include <hash.h>
#include <mysqld_error.h>
@@ -829,6 +833,17 @@ int do_sleep(struct st_query* q)
if (!*p)
die("Missing argument in sleep\n");
t.tv_usec = 0;
+
+#ifdef OS2
+
+ if (opt_sleep)
+ DosSleep( opt_sleep * 1000);
+ else
+ DosSleep( atof( p) * 1000);
+
+ return 0;
+
+#else
if (opt_sleep)
t.tv_sec = opt_sleep;
else
@@ -858,6 +873,7 @@ int do_sleep(struct st_query* q)
}
t.tv_usec *= dec_mul;
return select(0,0,0,0, &t);
+#endif
}
static void get_file_name(char *filename, struct st_query* q)
@@ -1881,8 +1897,8 @@ static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
static void var_free(void* v)
{
- my_free(((VAR*)v)->str_val, MYF(MY_WME));
- my_free(v, MYF(MY_WME));
+ my_free(((VAR*) v)->str_val, MYF(MY_WME));
+ my_free((char*) v, MYF(MY_WME));
}
@@ -2744,7 +2760,7 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
{
reg1 REPLACE *rep_pos;
reg2 REPLACE_STRING *rep_str;
- my_string to,end,pos,new;
+ my_string to,end,pos,new_str;
end=(to= *start) + *max_length-1;
rep_pos=rep+1;
@@ -2756,10 +2772,10 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
if (to == end)
{
(*max_length)+=8192;
- if (!(new=my_realloc(*start,*max_length,MYF(MY_WME))))
+ if (!(new_str=my_realloc(*start,*max_length,MYF(MY_WME))))
return (uint) -1;
- to=new+(to - *start);
- end=(*start=new)+ *max_length-1;
+ to=new_str+(to - *start);
+ end=(*start=new_str)+ *max_length-1;
}
*to++= *from++;
}
@@ -2771,10 +2787,10 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
if (to == end)
{
(*max_length)*=2;
- if (!(new=my_realloc(*start,*max_length,MYF(MY_WME))))
+ if (!(new_str=my_realloc(*start,*max_length,MYF(MY_WME))))
return (uint) -1;
- to=new+(to - *start);
- end=(*start=new)+ *max_length-1;
+ to=new_str+(to - *start);
+ end=(*start=new_str)+ *max_length-1;
}
*to++= *pos;
}