summaryrefslogtreecommitdiff
path: root/client/mysqldump.c
diff options
context:
space:
mode:
authorChad MILLER <chad@mysql.com>2009-03-09 16:58:47 -0400
committerChad MILLER <chad@mysql.com>2009-03-09 16:58:47 -0400
commit89a1db2bd228965707645ba346519b824f7a48e9 (patch)
tree6d7a530c873c00e7560e03add3a9ed345c86d026 /client/mysqldump.c
parente0bc00257617f2991d370b688bea7847dddbae8b (diff)
downloadmariadb-git-89a1db2bd228965707645ba346519b824f7a48e9.tar.gz
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.
Diffstat (limited to 'client/mysqldump.c')
-rw-r--r--client/mysqldump.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c
index c1eb07d7f8e..dea1b0b3659 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -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);