Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
6b8c1965
Commit
6b8c1965
authored
Jun 21, 2006
by
lars@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/users/lthalmann/bk/MERGE/mysql-5.0-merge
into mysql.com:/users/lthalmann/bk/MERGE/mysql-5.1-merge
parents
ed0e9852
6839e642
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
648 additions
and
452 deletions
+648
-452
client/mysqldump.c
client/mysqldump.c
+455
-439
mysql-test/r/mysqldump.result
mysql-test/r/mysqldump.result
+59
-13
mysql-test/r/rpl_auto_increment_11932.result
mysql-test/r/rpl_auto_increment_11932.result
+47
-0
mysql-test/r/sql_mode.result
mysql-test/r/sql_mode.result
+4
-0
mysql-test/t/mysqldump.test
mysql-test/t/mysqldump.test
+17
-0
mysql-test/t/rpl_auto_increment_11932.test
mysql-test/t/rpl_auto_increment_11932.test
+63
-0
mysql-test/t/sql_mode.test
mysql-test/t/sql_mode.test
+3
-0
No files found.
client/mysqldump.c
View file @
6b8c1965
...
...
@@ -133,8 +133,8 @@ static const char *mysql_universal_client_charset=
static
char
*
default_charset
;
static
CHARSET_INFO
*
charset_info
=
&
my_charset_latin1
;
const
char
*
default_dbug_option
=
"d:t:o,/tmp/mysqldump.trace"
;
/*
do we met VIEWs during tables scaning
*/
my_bool
was
_views
=
0
;
/*
have we seen any VIEWs during table scanning?
*/
my_bool
seen
_views
=
0
;
const
char
*
compatible_mode_names
[]
=
{
"MYSQL323"
,
"MYSQL40"
,
"POSTGRESQL"
,
"ORACLE"
,
"MSSQL"
,
"DB2"
,
...
...
@@ -1528,7 +1528,7 @@ static uint dump_routines_for_db(char *db)
ARGS
table - table name
db - db name
table_type - table type
ie "InnoDB
"
table_type - table type
, e.g. "MyISAM" or "InnoDB", but also "VIEW
"
ignore_flag - what we must particularly ignore - see IGNORE_ defines above
RETURN
...
...
@@ -1620,13 +1620,22 @@ static uint get_table_structure(char *table, char *db, char *table_type,
}
if
(
!
opt_xml
&&
opt_comments
)
{
if
(
strcmp
(
table_type
,
"VIEW"
)
==
0
)
/* view */
fprintf
(
sql_file
,
"
\n
--
\n
-- Temporary table structure for view %s
\n
--
\n\n
"
,
result_table
);
else
fprintf
(
sql_file
,
"
\n
--
\n
-- Table structure for table %s
\n
--
\n\n
"
,
result_table
);
check_io
(
sql_file
);
}
if
(
opt_drop
)
{
fprintf
(
sql_file
,
"DROP TABLE IF EXISTS %s;
\n
"
,
opt_quoted_table
);
/*
Even if the "table" is a view, we do a DROP TABLE here. The
view-specific code below fills in the DROP VIEW.
*/
fprintf
(
sql_file
,
"DROP TABLE IF EXISTS %s;
\n
"
,
opt_quoted_table
);
check_io
(
sql_file
);
}
...
...
@@ -1664,10 +1673,13 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{
if
(
opt_drop
)
{
/*
We have already dropped any table of the same name
above, so here we just drop the view.
*/
fprintf
(
sql_file
,
"/*!50001 DROP VIEW IF EXISTS %s*/;
\n
"
,
opt_quoted_table
);
fprintf
(
sql_file
,
"/*!50001 DROP TABLE IF EXISTS %s*/;
\n
"
,
opt_quoted_table
);
check_io
(
sql_file
);
}
...
...
@@ -1694,7 +1706,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
}
mysql_free_result
(
result
);
was
_views
=
1
;
seen
_views
=
1
;
DBUG_RETURN
(
0
);
}
...
...
@@ -2199,6 +2211,12 @@ static void dump_table(char *table, char *db)
*/
num_fields
=
get_table_structure
(
table
,
db
,
table_type
,
&
ignore_flag
);
/*
The "table" could be a view. If so, we don't do anything here.
*/
if
(
strcmp
(
table_type
,
"VIEW"
)
==
0
)
return
;
/* Check --no-data flag */
if
(
dFlag
)
{
...
...
@@ -2808,7 +2826,7 @@ static int dump_all_databases()
if
(
dump_all_tables_in_db
(
row
[
0
]))
result
=
1
;
}
if
(
was
_views
)
if
(
seen
_views
)
{
if
(
mysql_query
(
sock
,
"SHOW DATABASES"
)
||
!
(
tableres
=
mysql_store_result
(
sock
)))
...
...
@@ -2837,7 +2855,7 @@ static int dump_databases(char **db_names)
if
(
dump_all_tables_in_db
(
*
db
))
result
=
1
;
}
if
(
!
result
&&
was
_views
)
if
(
!
result
&&
seen
_views
)
{
for
(
db
=
db_names
;
*
db
;
db
++
)
{
...
...
@@ -3019,8 +3037,6 @@ static my_bool dump_all_views_in_db(char *database)
uint
numrows
;
char
table_buff
[
NAME_LEN
*
2
+
3
];
if
(
init_dumping
(
database
))
return
1
;
if
(
opt_xml
)
print_xml_tag1
(
md_result_file
,
""
,
"database name="
,
database
,
"
\n
"
);
if
(
lock_tables
)
...
...
@@ -3174,7 +3190,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
}
/* Dump each selected view */
if
(
was
_views
)
if
(
seen
_views
)
{
for
(
pos
=
dump_tables
;
pos
<
end
;
pos
++
)
get_view_structure
(
*
pos
,
db
);
...
...
@@ -3638,7 +3654,7 @@ static my_bool get_view_structure(char *table, char* db)
if
(
!
opt_xml
&&
opt_comments
)
{
fprintf
(
sql_file
,
"
\n
--
\n
--
V
iew structure for view %s
\n
--
\n\n
"
,
fprintf
(
sql_file
,
"
\n
--
\n
--
Final v
iew structure for view %s
\n
--
\n\n
"
,
result_table
);
check_io
(
sql_file
);
}
...
...
mysql-test/r/mysqldump.result
View file @
6b8c1965
...
...
@@ -1459,7 +1459,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
...
...
@@ -1871,7 +1870,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11)
) */;
...
...
@@ -1929,7 +1927,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
...
...
@@ -2022,7 +2019,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11),
`b` int(11),
...
...
@@ -2030,13 +2026,11 @@ DROP TABLE IF EXISTS `v1`;
) */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` int(11)
) */;
DROP TABLE IF EXISTS `v3`;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 DROP TABLE IF EXISTS `v3`*/;
/*!50001 CREATE TABLE `v3` (
`a` int(11),
`b` int(11),
...
...
@@ -2597,7 +2591,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v0`;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 CREATE TABLE `v0` (
`a` int(11),
`b` varchar(32),
...
...
@@ -2605,7 +2598,6 @@ DROP TABLE IF EXISTS `v0`;
) */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11),
`b` varchar(32),
...
...
@@ -2613,16 +2605,11 @@ DROP TABLE IF EXISTS `v1`;
) */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` int(11),
`b` varchar(32),
`c` varchar(32)
) */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
...
...
@@ -3021,3 +3008,62 @@ third ee3 root@localhost ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLE
drop database third;
set time_zone = 'SYSTEM';
use test;
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1 (id int);
create view v1 as select * from t1;
insert into t1 values (1232131);
insert into t1 values (4711);
insert into t1 values (3231);
insert into t1 values (0815);
/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*!40000 DROP DATABASE IF EXISTS `mysqldump_test_db`*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_test_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_test_db`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1232131),(4711),(3231),(815);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`id` int(11)
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v1` AS select `t1`.`id` AS `id` from `t1` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop view v1;
drop table t1;
drop database mysqldump_test_db;
mysql-test/r/rpl_auto_increment_11932.result
0 → 100644
View file @
6b8c1965
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop database if exists test1;
create database test1;
use test1;
CREATE TABLE `t1` (
`id` int(10) unsigned NOT NULL auto_increment,
`fname` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `t1` VALUES (1, 'blablabla');
CREATE TABLE `t2` (
`id` int(10) NOT NULL auto_increment,
`comment` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 ;
INSERT INTO `t2` VALUES (1, 'testtest 1');
INSERT INTO `t2` VALUES (2, 'test 2');
CREATE PROCEDURE simpleproc3 ()
NOT DETERMINISTIC
BEGIN
INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1');
INSERT INTO t1 (fname) VALUES('test');
END
$
CALL simpleproc3();
select * from t2;
id comment
1 testtest 1
2 test 2
TRUNCATE TABLE `t1`;
CALL simpleproc3();
select * from t1;
id fname
1 testtest 1
2 test
use test1;
select * from t1;
id fname
1 testtest 1
2 test
drop database test1;
drop database test1;
mysql-test/r/sql_mode.result
View file @
6b8c1965
...
...
@@ -467,6 +467,10 @@ set sql_mode=2097152;
select @@sql_mode;
@@sql_mode
STRICT_TRANS_TABLES
set sql_mode=4194304;
select @@sql_mode;
@@sql_mode
STRICT_ALL_TABLES
set sql_mode=16384+(65536*4);
select @@sql_mode;
@@sql_mode
...
...
mysql-test/t/mysqldump.test
View file @
6b8c1965
...
...
@@ -1252,3 +1252,20 @@ set time_zone = 'SYSTEM';
use
test
;
#####
#
# BUG#17201 Spurious 'DROP DATABASE' in output,
# also confusion between tables and views.
# Example code from Markus Popp
create
database
mysqldump_test_db
;
use
mysqldump_test_db
;
create
table
t1
(
id
int
);
create
view
v1
as
select
*
from
t1
;
insert
into
t1
values
(
1232131
);
insert
into
t1
values
(
4711
);
insert
into
t1
values
(
3231
);
insert
into
t1
values
(
0815
);
--
exec
$MYSQL_DUMP
--
skip
-
comments
--
add
-
drop
-
database
--
databases
mysqldump_test_db
drop
view
v1
;
drop
table
t1
;
drop
database
mysqldump_test_db
;
mysql-test/t/rpl_auto_increment_11932.test
0 → 100644
View file @
6b8c1965
#
# Test of auto_increment
# BUG#11932
#
# Bug reported that master and slave get out of sync after TRUNCATE
# TABLE.
#
# Test supplied by Are Casilla
source
include
/
master
-
slave
.
inc
;
--
disable_warnings
connection
master
;
drop
database
if
exists
test1
;
--
enable_warnings
create
database
test1
;
use
test1
;
CREATE
TABLE
`t1`
(
`id`
int
(
10
)
unsigned
NOT
NULL
auto_increment
,
`fname`
varchar
(
100
)
default
NULL
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
latin1
AUTO_INCREMENT
=
2
;
INSERT
INTO
`t1`
VALUES
(
1
,
'blablabla'
);
CREATE
TABLE
`t2`
(
`id`
int
(
10
)
NOT
NULL
auto_increment
,
`comment`
varchar
(
255
)
NOT
NULL
default
''
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
AUTO_INCREMENT
=
3
;
INSERT
INTO
`t2`
VALUES
(
1
,
'testtest 1'
);
INSERT
INTO
`t2`
VALUES
(
2
,
'test 2'
);
DELIMITER
$
;
CREATE
PROCEDURE
simpleproc3
()
NOT
DETERMINISTIC
BEGIN
INSERT
INTO
t1
(
fname
)
(
SELECT
t2
.
comment
FROM
t2
WHERE
t2
.
id
=
'1'
);
INSERT
INTO
t1
(
fname
)
VALUES
(
'test'
);
END
$
DELIMITER
;
$
CALL
simpleproc3
();
select
*
from
t2
;
TRUNCATE
TABLE
`t1`
;
CALL
simpleproc3
();
select
*
from
t1
;
save_master_pos
;
connection
slave
;
sync_with_master
;
use
test1
;
select
*
from
t1
;
drop
database
test1
;
connection
master
;
drop
database
test1
;
mysql-test/t/sql_mode.test
View file @
6b8c1965
...
...
@@ -258,6 +258,9 @@ drop table t1, t2;
select
@@
sql_mode
;
set
sql_mode
=
2097152
;
select
@@
sql_mode
;
# BUG#14675
set
sql_mode
=
4194304
;
select
@@
sql_mode
;
set
sql_mode
=
16384
+
(
65536
*
4
);
select
@@
sql_mode
;
--
error
1231
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment