1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug#42635: mysqldump includes views that were excluded using the \

--ignore-table option

mysqldump would correctly omit temporary tables for views, but would
incorrectly still emit all CREATE VIEW statements.

Backport a fix from 5.1, where we capture the names we want to emit
views for in one pass (the placeholder tables) and in the pass where
we actually emit the views, we don't emit a view if it wasn't in that
list.
This commit is contained in:
Chad MILLER
2009-03-09 16:58:47 -04:00
parent e0bc002576
commit 89a1db2bd2
3 changed files with 87 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -3103,6 +3103,11 @@ static my_bool dump_all_views_in_db(char *database)
char *table;
uint numrows;
char table_buff[NAME_LEN*2+3];
char hash_key[2*NAME_LEN+2]; /* "db.tablename" */
char *afterdot;
afterdot= strmov(hash_key, database);
*afterdot++= '.';
if (init_dumping(database, init_dumping_views))
return 1;
@ -3112,10 +3117,15 @@ static my_bool dump_all_views_in_db(char *database)
{
DYNAMIC_STRING query;
init_dynamic_string_checked(&query, "LOCK TABLES ", 256, 1024);
for (numrows= 0 ; (table= getTableName(1)); numrows++)
for (numrows= 0 ; (table= getTableName(1)); )
{
dynstr_append_checked(&query, quote_name(table, table_buff, 1));
dynstr_append_checked(&query, " READ /*!32311 LOCAL */,");
char *end= strmov(afterdot, table);
if (include_table((uchar*) hash_key,end - hash_key))
{
numrows++;
dynstr_append_checked(&query, quote_name(table, table_buff, 1));
dynstr_append_checked(&query, " READ /*!32311 LOCAL */,");
}
}
if (numrows && mysql_real_query(mysql, query.str, query.length-1))
DB_error(mysql, "when using LOCK TABLES");
@ -3129,7 +3139,11 @@ static my_bool dump_all_views_in_db(char *database)
/* We shall continue here, if --force was given */
}
while ((table= getTableName(0)))
get_view_structure(table, database);
{
char *end= strmov(afterdot, table);
if (include_table((uchar*) hash_key, end - hash_key))
get_view_structure(table, database);
}
if (opt_xml)
{
fputs("</database>\n", md_result_file);