Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-4.0

into a80-186-24-72.elisa-laajakaista.fi:/home/my/bk/mysql-4.0
parents 49c0c59b 6bc03b14
...@@ -39,6 +39,7 @@ hf@deer.mysql.r18.ru ...@@ -39,6 +39,7 @@ hf@deer.mysql.r18.ru
hf@genie.(none) hf@genie.(none)
igor@hundin.mysql.fi igor@hundin.mysql.fi
igor@rurik.mysql.com igor@rurik.mysql.com
jani@a80-186-24-72.elisa-laajakaista.fi
jani@dsl-jkl1657.dial.inet.fi jani@dsl-jkl1657.dial.inet.fi
jani@hynda.(none) jani@hynda.(none)
jani@hynda.mysql.fi jani@hynda.mysql.fi
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
** Added --single-transaction option 06/06/2002 by Peter Zaitsev ** Added --single-transaction option 06/06/2002 by Peter Zaitsev
*/ */
#define DUMP_VERSION "9.10" #define DUMP_VERSION "9.11"
#include <my_global.h> #include <my_global.h>
#include <my_sys.h> #include <my_sys.h>
...@@ -938,18 +938,32 @@ static char *field_escape(char *to,const char *from,uint length) ...@@ -938,18 +938,32 @@ static char *field_escape(char *to,const char *from,uint length)
} /* field_escape */ } /* field_escape */
static char *alloc_query_str(ulong size)
{
char *query;
if (!(query= (char*) my_malloc(size, MYF(MY_WME))))
{
ignore_errors= 0; /* Fatal error */
safe_exit(EX_MYSQLERR); /* Force exit */
}
return query;
}
/* /*
** dumpTable saves database contents as a series of INSERT statements. ** dumpTable saves database contents as a series of INSERT statements.
*/ */
static void dumpTable(uint numFields, char *table) static void dumpTable(uint numFields, char *table)
{ {
char query[QUERY_LENGTH], *end, buff[256],table_buff[NAME_LEN+3]; char query_buf[QUERY_LENGTH], *end, buff[256],table_buff[NAME_LEN+3];
char *result_table, table_buff2[NAME_LEN*2+3], *opt_quoted_table; char *result_table, table_buff2[NAME_LEN*2+3], *opt_quoted_table;
char *query= query_buf;
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_FIELD *field; MYSQL_FIELD *field;
MYSQL_ROW row; MYSQL_ROW row;
ulong rownr, row_break, total_length, init_length; ulong rownr, row_break, total_length, init_length;
const char *table_type; const char *table_type;
int error= 0;
result_table= quote_name(table,table_buff, 1); result_table= quote_name(table,table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0); opt_quoted_table= quote_name(table, table_buff2, 0);
...@@ -995,8 +1009,11 @@ static void dumpTable(uint numFields, char *table) ...@@ -995,8 +1009,11 @@ static void dumpTable(uint numFields, char *table)
sprintf(buff," FROM %s", result_table); sprintf(buff," FROM %s", result_table);
end= strmov(end,buff); end= strmov(end,buff);
if (where) if (where)
end= strxmov(end, " WHERE ",where,NullS); {
if (mysql_query(sock, query)) query= alloc_query_str((ulong) (strlen(where) + (end - query) + 10));
end= strxmov(query, query_buf, " WHERE ", where, NullS);
}
if (mysql_real_query(sock, query, (uint) (end - query)))
{ {
DBerror(sock, "when executing 'SELECT INTO OUTFILE'"); DBerror(sock, "when executing 'SELECT INTO OUTFILE'");
return; return;
...@@ -1013,14 +1030,16 @@ static void dumpTable(uint numFields, char *table) ...@@ -1013,14 +1030,16 @@ static void dumpTable(uint numFields, char *table)
{ {
if (!opt_xml && opt_comments) if (!opt_xml && opt_comments)
fprintf(md_result_file,"-- WHERE: %s\n",where); fprintf(md_result_file,"-- WHERE: %s\n",where);
strxmov(strend(query), " WHERE ",where,NullS); query= alloc_query_str((ulong) (strlen(where) + strlen(query) + 10));
strxmov(query, query_buf, " WHERE ", where, NullS);
} }
if (!opt_xml) if (!opt_xml)
fputs("\n", md_result_file); fputs("\n", md_result_file);
if (mysql_query(sock, query)) if (mysql_query(sock, query))
{ {
DBerror(sock, "when retrieving data from server"); DBerror(sock, "when retrieving data from server");
return; error= EX_CONSCHECK;
goto err;
} }
if (quick) if (quick)
res=mysql_use_result(sock); res=mysql_use_result(sock);
...@@ -1029,7 +1048,8 @@ static void dumpTable(uint numFields, char *table) ...@@ -1029,7 +1048,8 @@ static void dumpTable(uint numFields, char *table)
if (!res) if (!res)
{ {
DBerror(sock, "when retrieving data from server"); DBerror(sock, "when retrieving data from server");
return; error= EX_CONSCHECK;
goto err;
} }
if (verbose) if (verbose)
fprintf(stderr, "-- Retrieving rows...\n"); fprintf(stderr, "-- Retrieving rows...\n");
...@@ -1037,8 +1057,8 @@ static void dumpTable(uint numFields, char *table) ...@@ -1037,8 +1057,8 @@ static void dumpTable(uint numFields, char *table)
{ {
fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n", fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n",
my_progname, result_table); my_progname, result_table);
safe_exit(EX_CONSCHECK); error= EX_CONSCHECK;
return; goto err;
} }
if (opt_disable_keys) if (opt_disable_keys)
...@@ -1076,8 +1096,8 @@ static void dumpTable(uint numFields, char *table) ...@@ -1076,8 +1096,8 @@ static void dumpTable(uint numFields, char *table)
sprintf(query,"%s: Not enough fields from table %s! Aborting.\n", sprintf(query,"%s: Not enough fields from table %s! Aborting.\n",
my_progname, result_table); my_progname, result_table);
fputs(query,stderr); fputs(query,stderr);
safe_exit(EX_CONSCHECK); error= EX_CONSCHECK;
return; goto err;
} }
if (extended_insert) if (extended_insert)
{ {
...@@ -1096,7 +1116,8 @@ static void dumpTable(uint numFields, char *table) ...@@ -1096,7 +1116,8 @@ static void dumpTable(uint numFields, char *table)
if (dynstr_realloc(&extended_row,length * 2+2)) if (dynstr_realloc(&extended_row,length * 2+2))
{ {
fputs("Aborting dump (out of memory)",stderr); fputs("Aborting dump (out of memory)",stderr);
safe_exit(EX_EOM); error= EX_EOM;
goto err;
} }
dynstr_append(&extended_row,"\'"); dynstr_append(&extended_row,"\'");
extended_row.length += extended_row.length +=
...@@ -1131,7 +1152,8 @@ static void dumpTable(uint numFields, char *table) ...@@ -1131,7 +1152,8 @@ static void dumpTable(uint numFields, char *table)
else if (dynstr_append(&extended_row,"NULL")) else if (dynstr_append(&extended_row,"NULL"))
{ {
fputs("Aborting dump (out of memory)",stderr); fputs("Aborting dump (out of memory)",stderr);
safe_exit(EX_EOM); error= EX_EOM;
goto err;
} }
} }
else else
...@@ -1229,8 +1251,8 @@ static void dumpTable(uint numFields, char *table) ...@@ -1229,8 +1251,8 @@ static void dumpTable(uint numFields, char *table)
result_table, result_table,
rownr); rownr);
fputs(query,stderr); fputs(query,stderr);
safe_exit(EX_CONSCHECK); error= EX_CONSCHECK;
return; goto err;
} }
if (opt_lock) if (opt_lock)
fputs("UNLOCK TABLES;\n", md_result_file); fputs("UNLOCK TABLES;\n", md_result_file);
...@@ -1240,7 +1262,16 @@ static void dumpTable(uint numFields, char *table) ...@@ -1240,7 +1262,16 @@ static void dumpTable(uint numFields, char *table)
if (opt_autocommit) if (opt_autocommit)
fprintf(md_result_file, "commit;\n"); fprintf(md_result_file, "commit;\n");
mysql_free_result(res); mysql_free_result(res);
} if (query != query_buf)
my_free(query, MYF(MY_ALLOW_ZERO_PTR));
}
return;
err:
if (query != query_buf)
my_free(query, MYF(MY_ALLOW_ZERO_PTR));
safe_exit(error);
return;
} /* dumpTable */ } /* dumpTable */
......
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