mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge with 4.0.20
BitKeeper/etc/logging_ok: auto-union client/mysql.cc: Auto merged client/mysqltest.c: Auto merged innobase/btr/btr0btr.c: Auto merged innobase/dict/dict0dict.c: Auto merged innobase/dict/dict0load.c: Auto merged innobase/eval/eval0eval.c: Auto merged innobase/ibuf/ibuf0ibuf.c: Auto merged innobase/include/ut0mem.h: Auto merged innobase/lock/lock0lock.c: Auto merged innobase/row/row0ins.c: Auto merged innobase/row/row0mysql.c: Auto merged innobase/row/row0sel.c: Auto merged innobase/row/row0umod.c: Auto merged innobase/row/row0upd.c: Auto merged innobase/trx/trx0trx.c: Auto merged innobase/ut/ut0dbg.c: Auto merged innobase/ut/ut0mem.c: Auto merged myisam/mi_dynrec.c: Auto merged mysql-test/r/innodb.result: Auto merged mysql-test/t/fulltext.test: Auto merged mysql-test/t/rpl_rotate_logs.test: Auto merged scripts/make_binary_distribution.sh: Auto merged sql/ha_innodb.cc: Auto merged sql/item_func.cc: Auto merged sql/slave.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_show.cc: Auto merged innobase/os/os0file.c: Merge with 4.0.20 Ensure that we call F_UNLCK for files on which we call F_WRLCK. This is to ensure that this code will be portable accross most platforms. myisam/ft_boolean_search.c: Merge with 4.0.20 (keep original file) myisam/ft_parser.c: Merge with 4.0.20 (keep original file) myisam/ftdefs.h: Merge with 4.0.20 (keep original file)
This commit is contained in:
@ -1264,18 +1264,32 @@ static char *field_escape(char *to,const char *from,uint length)
|
||||
} /* 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.
|
||||
*/
|
||||
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 *query= query_buf;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_FIELD *field;
|
||||
MYSQL_ROW row;
|
||||
ulong rownr, row_break, total_length, init_length;
|
||||
const char *table_type;
|
||||
int error= 0;
|
||||
|
||||
result_table= quote_name(table,table_buff, 1);
|
||||
opt_quoted_table= quote_name(table, table_buff2, 0);
|
||||
@ -1321,8 +1335,11 @@ static void dumpTable(uint numFields, char *table)
|
||||
sprintf(buff," FROM %s", result_table);
|
||||
end= strmov(end,buff);
|
||||
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'");
|
||||
return;
|
||||
@ -1339,14 +1356,16 @@ static void dumpTable(uint numFields, char *table)
|
||||
{
|
||||
if (!opt_xml && opt_comments)
|
||||
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 && !opt_compact)
|
||||
fputs("\n", md_result_file);
|
||||
if (mysql_query(sock, query))
|
||||
{
|
||||
DBerror(sock, "when retrieving data from server");
|
||||
return;
|
||||
error= EX_CONSCHECK;
|
||||
goto err;
|
||||
}
|
||||
if (quick)
|
||||
res=mysql_use_result(sock);
|
||||
@ -1355,7 +1374,8 @@ static void dumpTable(uint numFields, char *table)
|
||||
if (!res)
|
||||
{
|
||||
DBerror(sock, "when retrieving data from server");
|
||||
return;
|
||||
error= EX_CONSCHECK;
|
||||
goto err;
|
||||
}
|
||||
if (verbose)
|
||||
fprintf(stderr, "-- Retrieving rows...\n");
|
||||
@ -1363,8 +1383,8 @@ static void dumpTable(uint numFields, char *table)
|
||||
{
|
||||
fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n",
|
||||
my_progname, result_table);
|
||||
safe_exit(EX_CONSCHECK);
|
||||
return;
|
||||
error= EX_CONSCHECK;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (opt_disable_keys)
|
||||
@ -1402,8 +1422,8 @@ static void dumpTable(uint numFields, char *table)
|
||||
sprintf(query,"%s: Not enough fields from table %s! Aborting.\n",
|
||||
my_progname, result_table);
|
||||
fputs(query,stderr);
|
||||
safe_exit(EX_CONSCHECK);
|
||||
return;
|
||||
error= EX_CONSCHECK;
|
||||
goto err;
|
||||
}
|
||||
if (extended_insert)
|
||||
{
|
||||
@ -1422,7 +1442,8 @@ static void dumpTable(uint numFields, char *table)
|
||||
if (dynstr_realloc(&extended_row,length * 2+2))
|
||||
{
|
||||
fputs("Aborting dump (out of memory)",stderr);
|
||||
safe_exit(EX_EOM);
|
||||
error= EX_EOM;
|
||||
goto err;
|
||||
}
|
||||
dynstr_append(&extended_row,"'");
|
||||
extended_row.length +=
|
||||
@ -1458,7 +1479,8 @@ static void dumpTable(uint numFields, char *table)
|
||||
else if (dynstr_append(&extended_row,"NULL"))
|
||||
{
|
||||
fputs("Aborting dump (out of memory)",stderr);
|
||||
safe_exit(EX_EOM);
|
||||
error= EX_EOM;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1552,8 +1574,8 @@ static void dumpTable(uint numFields, char *table)
|
||||
result_table,
|
||||
rownr);
|
||||
fputs(query,stderr);
|
||||
safe_exit(EX_CONSCHECK);
|
||||
return;
|
||||
error= EX_CONSCHECK;
|
||||
goto err;
|
||||
}
|
||||
if (opt_lock)
|
||||
fputs("UNLOCK TABLES;\n", md_result_file);
|
||||
@ -1563,7 +1585,16 @@ static void dumpTable(uint numFields, char *table)
|
||||
if (opt_autocommit)
|
||||
fprintf(md_result_file, "commit;\n");
|
||||
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 */
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user