Commit ff102add authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

fix xml with view

parent 2264bb01
...@@ -1161,6 +1161,12 @@ static uint getTableStructure(char *table, char* db) ...@@ -1161,6 +1161,12 @@ static uint getTableStructure(char *table, char* db)
sprintf(buff,"show keys from %s", result_table); sprintf(buff,"show keys from %s", result_table);
if (mysql_query(sock, buff)) if (mysql_query(sock, buff))
{ {
if (mysql_errno(sock) == ER_WRONG_OBJECT)
{
/* it is VIEW */
fputs("\t\t<options Comment=\"view\" />\n", sql_file);
goto continue_xml;
}
fprintf(stderr, "%s: Can't get keys for table %s (%s)\n", fprintf(stderr, "%s: Can't get keys for table %s (%s)\n",
my_progname, result_table, mysql_error(sock)); my_progname, result_table, mysql_error(sock));
if (path) if (path)
...@@ -1268,6 +1274,7 @@ static uint getTableStructure(char *table, char* db) ...@@ -1268,6 +1274,7 @@ static uint getTableStructure(char *table, char* db)
} }
mysql_free_result(tableRes); /* Is always safe to free */ mysql_free_result(tableRes); /* Is always safe to free */
} }
continue_xml:
if (!opt_xml) if (!opt_xml)
fputs(";\n", sql_file); fputs(";\n", sql_file);
else else
...@@ -2134,9 +2141,14 @@ static const char *check_if_ignore_table(const char *table_name) ...@@ -2134,9 +2141,14 @@ static const char *check_if_ignore_table(const char *table_name)
mysql_free_result(res); mysql_free_result(res);
return 0; /* assume table is ok */ return 0; /* assume table is ok */
} }
if (strcmp(row[1], (result= "MRG_MyISAM")) && if (!(row[1]))
strcmp(row[1], (result= "MRG_ISAM"))) result= "VIEW";
result= 0; else
{
if (strcmp(row[1], (result= "MRG_MyISAM")) &&
strcmp(row[1], (result= "MRG_ISAM")))
result= 0;
}
mysql_free_result(res); mysql_free_result(res);
return result; return result;
} }
......
...@@ -332,3 +332,60 @@ CREATE TABLE `t1` ( ...@@ -332,3 +332,60 @@ CREATE TABLE `t1` (
2 2
3 3
drop table t1; drop table t1;
create table t1(a int);
create view v1 as select * from t1;
-- MySQL dump 10.7
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version 5.0.2-alpha-valgrind-max-debug-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;
--
-- Table structure for table `t1`
--
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `t1`
--
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
--
-- Table structure for table `v1`
--
DROP TABLE IF EXISTS `v1`;
--
-- View structure for view `v1`
--
DROP VIEW IF EXISTS `v1`;
CREATE VIEW `test`.`v1` AS select `test`.`t1`.`a` AS `a` from `test`.`t1`;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
drop view v1;
drop table t1;
...@@ -127,3 +127,12 @@ insert into t1 values (1),(2),(3); ...@@ -127,3 +127,12 @@ insert into t1 values (1),(2),(3);
--exec rm $MYSQL_TEST_DIR/var/tmp/t1.sql --exec rm $MYSQL_TEST_DIR/var/tmp/t1.sql
--exec rm $MYSQL_TEST_DIR/var/tmp/t1.txt --exec rm $MYSQL_TEST_DIR/var/tmp/t1.txt
drop table t1; drop table t1;
#
# dump of view
#
create table t1(a int);
create view v1 as select * from t1;
--exec $MYSQL_DUMP test
drop view v1;
drop table t1;
...@@ -913,6 +913,9 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, ...@@ -913,6 +913,9 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
*/ */
{ {
char path[FN_REFLEN]; char path[FN_REFLEN];
TABLE tab;
if (!table)
table= &tab;
strxnmov(path, FN_REFLEN, mysql_data_home, "/", table_list->db, "/", strxnmov(path, FN_REFLEN, mysql_data_home, "/", table_list->db, "/",
table_list->real_name, reg_ext, NullS); table_list->real_name, reg_ext, NullS);
(void) unpack_filename(path, path); (void) unpack_filename(path, path);
......
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