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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
a1c70022
Commit
a1c70022
authored
Sep 11, 2006
by
lars/lthalmann@dl145k.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
1dfc8498
6ad198e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
206 additions
and
47 deletions
+206
-47
client/mysqldump.c
client/mysqldump.c
+55
-47
mysql-test/r/mysqldump.result
mysql-test/r/mysqldump.result
+125
-0
mysql-test/t/mysqldump.test
mysql-test/t/mysqldump.test
+20
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+6
-0
No files found.
client/mysqldump.c
View file @
a1c70022
...
@@ -663,13 +663,13 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
...
@@ -663,13 +663,13 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
tty_password
=
1
;
tty_password
=
1
;
break
;
break
;
case
'r'
:
case
'r'
:
if
(
!
(
md_result_file
=
my_fopen
(
argument
,
O_WRONLY
|
FILE_BINARY
,
if
(
!
(
md_result_file
=
my_fopen
(
argument
,
O_WRONLY
|
FILE_BINARY
,
MYF
(
MY_WME
))))
MYF
(
MY_WME
))))
exit
(
1
);
exit
(
1
);
break
;
break
;
case
'W'
:
case
'W'
:
#ifdef __WIN__
#ifdef __WIN__
opt_protocol
=
MYSQL_PROTOCOL_PIPE
;
opt_protocol
=
MYSQL_PROTOCOL_PIPE
;
#endif
#endif
break
;
break
;
case
'N'
:
case
'N'
:
...
@@ -684,7 +684,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
...
@@ -684,7 +684,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#include <sslopt-case.h>
#include <sslopt-case.h>
case
'V'
:
print_version
();
exit
(
0
);
case
'V'
:
print_version
();
exit
(
0
);
case
'X'
:
case
'X'
:
opt_xml
=
1
;
opt_xml
=
1
;
extended_insert
=
opt_drop
=
opt_lock
=
extended_insert
=
opt_drop
=
opt_lock
=
opt_disable_keys
=
opt_autocommit
=
opt_create_db
=
0
;
opt_disable_keys
=
opt_autocommit
=
opt_create_db
=
0
;
break
;
break
;
...
@@ -1572,7 +1572,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
...
@@ -1572,7 +1572,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
const
char
*
insert_option
;
const
char
*
insert_option
;
char
name_buff
[
NAME_LEN
+
3
],
table_buff
[
NAME_LEN
*
2
+
3
];
char
name_buff
[
NAME_LEN
+
3
],
table_buff
[
NAME_LEN
*
2
+
3
];
char
table_buff2
[
NAME_LEN
*
2
+
3
],
query_buff
[
QUERY_LENGTH
];
char
table_buff2
[
NAME_LEN
*
2
+
3
],
query_buff
[
QUERY_LENGTH
];
FILE
*
sql_file
=
md_result_file
;
FILE
*
sql_file
=
md_result_file
;
int
len
;
int
len
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
...
@@ -1616,7 +1616,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
...
@@ -1616,7 +1616,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
opt_quoted_table
=
quote_name
(
table
,
table_buff2
,
0
);
opt_quoted_table
=
quote_name
(
table
,
table_buff2
,
0
);
if
(
opt_order_by_primary
)
if
(
opt_order_by_primary
)
order_by
=
primary_key_fields
(
result_table
);
order_by
=
primary_key_fields
(
result_table
);
if
(
!
opt_xml
&&
!
mysql_query_with_error_report
(
mysql
,
0
,
query_buff
))
if
(
!
opt_xml
&&
!
mysql_query_with_error_report
(
mysql
,
0
,
query_buff
))
{
{
...
@@ -1668,7 +1668,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
...
@@ -1668,7 +1668,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
field
=
mysql_fetch_field_direct
(
result
,
0
);
field
=
mysql_fetch_field_direct
(
result
,
0
);
if
(
strcmp
(
field
->
name
,
"View"
)
==
0
)
if
(
strcmp
(
field
->
name
,
"View"
)
==
0
)
{
{
char
*
scv_buff
=
NULL
;
char
*
scv_buff
=
NULL
;
verbose_msg
(
"-- It's a view, create dummy table for view
\n
"
);
verbose_msg
(
"-- It's a view, create dummy table for view
\n
"
);
...
@@ -1705,7 +1705,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
...
@@ -1705,7 +1705,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
my_free
(
scv_buff
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
scv_buff
,
MYF
(
MY_ALLOW_ZERO_PTR
));
safe_exit
(
EX_MYSQLERR
);
safe_exit
(
EX_MYSQLERR
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
else
else
my_free
(
scv_buff
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
scv_buff
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
@@ -2075,7 +2075,7 @@ static void dump_triggers_for_table (char *table, char *db)
...
@@ -2075,7 +2075,7 @@ static void dump_triggers_for_table (char *table, char *db)
char
name_buff
[
NAME_LEN
*
4
+
3
],
table_buff
[
NAME_LEN
*
2
+
3
];
char
name_buff
[
NAME_LEN
*
4
+
3
],
table_buff
[
NAME_LEN
*
2
+
3
];
char
query_buff
[
QUERY_LENGTH
];
char
query_buff
[
QUERY_LENGTH
];
uint
old_opt_compatible_mode
=
opt_compatible_mode
;
uint
old_opt_compatible_mode
=
opt_compatible_mode
;
FILE
*
sql_file
=
md_result_file
;
FILE
*
sql_file
=
md_result_file
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
...
@@ -2319,15 +2319,15 @@ static void dump_table(char *table, char *db)
...
@@ -2319,15 +2319,15 @@ static void dump_table(char *table, char *db)
end
=
strmov
(
end
,
buff
);
end
=
strmov
(
end
,
buff
);
if
(
where
||
order_by
)
if
(
where
||
order_by
)
{
{
query
=
alloc_query_str
((
ulong
)
((
end
-
query
)
+
1
+
query
=
alloc_query_str
((
ulong
)
((
end
-
query
)
+
1
+
(
where
?
strlen
(
where
)
+
7
:
0
)
+
(
where
?
strlen
(
where
)
+
7
:
0
)
+
(
order_by
?
strlen
(
order_by
)
+
10
:
0
)));
(
order_by
?
strlen
(
order_by
)
+
10
:
0
)));
end
=
strmov
(
query
,
query_buf
);
end
=
strmov
(
query
,
query_buf
);
if
(
where
)
if
(
where
)
end
=
strxmov
(
end
,
" WHERE "
,
where
,
NullS
);
end
=
strxmov
(
end
,
" WHERE "
,
where
,
NullS
);
if
(
order_by
)
if
(
order_by
)
end
=
strxmov
(
end
,
" ORDER BY "
,
order_by
,
NullS
);
end
=
strxmov
(
end
,
" ORDER BY "
,
order_by
,
NullS
);
}
}
if
(
mysql_real_query
(
mysql
,
query
,
(
uint
)
(
end
-
query
)))
if
(
mysql_real_query
(
mysql
,
query
,
(
uint
)
(
end
-
query
)))
{
{
...
@@ -2348,10 +2348,10 @@ static void dump_table(char *table, char *db)
...
@@ -2348,10 +2348,10 @@ static void dump_table(char *table, char *db)
result_table
);
result_table
);
if
(
where
||
order_by
)
if
(
where
||
order_by
)
{
{
query
=
alloc_query_str
((
ulong
)
(
strlen
(
query
)
+
1
+
query
=
alloc_query_str
((
ulong
)
(
strlen
(
query
)
+
1
+
(
where
?
strlen
(
where
)
+
7
:
0
)
+
(
where
?
strlen
(
where
)
+
7
:
0
)
+
(
order_by
?
strlen
(
order_by
)
+
10
:
0
)));
(
order_by
?
strlen
(
order_by
)
+
10
:
0
)));
end
=
strmov
(
query
,
query_buf
);
end
=
strmov
(
query
,
query_buf
);
if
(
where
)
if
(
where
)
{
{
...
@@ -2360,7 +2360,7 @@ static void dump_table(char *table, char *db)
...
@@ -2360,7 +2360,7 @@ static void dump_table(char *table, char *db)
fprintf
(
md_result_file
,
"-- WHERE: %s
\n
"
,
where
);
fprintf
(
md_result_file
,
"-- WHERE: %s
\n
"
,
where
);
check_io
(
md_result_file
);
check_io
(
md_result_file
);
}
}
end
=
strxmov
(
end
,
" WHERE "
,
where
,
NullS
);
end
=
strxmov
(
end
,
" WHERE "
,
where
,
NullS
);
}
}
if
(
order_by
)
if
(
order_by
)
{
{
...
@@ -2369,7 +2369,7 @@ static void dump_table(char *table, char *db)
...
@@ -2369,7 +2369,7 @@ static void dump_table(char *table, char *db)
fprintf
(
md_result_file
,
"-- ORDER BY: %s
\n
"
,
order_by
);
fprintf
(
md_result_file
,
"-- ORDER BY: %s
\n
"
,
order_by
);
check_io
(
md_result_file
);
check_io
(
md_result_file
);
}
}
end
=
strxmov
(
end
,
" ORDER BY "
,
order_by
,
NullS
);
end
=
strxmov
(
end
,
" ORDER BY "
,
order_by
,
NullS
);
}
}
}
}
if
(
!
opt_xml
&&
!
opt_compact
)
if
(
!
opt_xml
&&
!
opt_compact
)
...
@@ -2442,12 +2442,12 @@ static void dump_table(char *table, char *db)
...
@@ -2442,12 +2442,12 @@ static void dump_table(char *table, char *db)
check_io
(
md_result_file
);
check_io
(
md_result_file
);
}
}
for
(
i
=
0
;
i
<
mysql_num_fields
(
res
);
i
++
)
for
(
i
=
0
;
i
<
mysql_num_fields
(
res
);
i
++
)
{
{
int
is_blob
;
int
is_blob
;
ulong
length
=
lengths
[
i
];
ulong
length
=
lengths
[
i
];
if
(
!
(
field
=
mysql_fetch_field
(
res
)))
if
(
!
(
field
=
mysql_fetch_field
(
res
)))
{
{
my_snprintf
(
query
,
QUERY_LENGTH
,
my_snprintf
(
query
,
QUERY_LENGTH
,
"%s: Not enough fields from table %s! Aborting.
\n
"
,
"%s: Not enough fields from table %s! Aborting.
\n
"
,
...
@@ -2519,7 +2519,7 @@ static void dump_table(char *table, char *db)
...
@@ -2519,7 +2519,7 @@ static void dump_table(char *table, char *db)
else
else
{
{
/* change any strings ("inf", "-inf", "nan") into NULL */
/* change any strings ("inf", "-inf", "nan") into NULL */
char
*
ptr
=
row
[
i
];
char
*
ptr
=
row
[
i
];
if
(
my_isalpha
(
charset_info
,
*
ptr
)
||
(
*
ptr
==
'-'
&&
if
(
my_isalpha
(
charset_info
,
*
ptr
)
||
(
*
ptr
==
'-'
&&
my_isalpha
(
charset_info
,
ptr
[
1
])))
my_isalpha
(
charset_info
,
ptr
[
1
])))
dynstr_append
(
&
extended_row
,
"NULL"
);
dynstr_append
(
&
extended_row
,
"NULL"
);
...
@@ -2579,7 +2579,7 @@ static void dump_table(char *table, char *db)
...
@@ -2579,7 +2579,7 @@ static void dump_table(char *table, char *db)
else
else
{
{
/* change any strings ("inf", "-inf", "nan") into NULL */
/* change any strings ("inf", "-inf", "nan") into NULL */
char
*
ptr
=
row
[
i
];
char
*
ptr
=
row
[
i
];
if
(
opt_xml
)
if
(
opt_xml
)
{
{
print_xml_tag1
(
md_result_file
,
"
\t\t
"
,
"field name="
,
print_xml_tag1
(
md_result_file
,
"
\t\t
"
,
"field name="
,
...
@@ -2625,10 +2625,10 @@ static void dump_table(char *table, char *db)
...
@@ -2625,10 +2625,10 @@ static void dump_table(char *table, char *db)
{
{
ulong
row_length
;
ulong
row_length
;
dynstr_append
(
&
extended_row
,
")"
);
dynstr_append
(
&
extended_row
,
")"
);
row_length
=
2
+
extended_row
.
length
;
row_length
=
2
+
extended_row
.
length
;
if
(
total_length
+
row_length
<
opt_net_buffer_length
)
if
(
total_length
+
row_length
<
opt_net_buffer_length
)
{
{
total_length
+=
row_length
;
total_length
+=
row_length
;
fputc
(
','
,
md_result_file
);
/* Always row break */
fputc
(
','
,
md_result_file
);
/* Always row break */
fputs
(
extended_row
.
str
,
md_result_file
);
fputs
(
extended_row
.
str
,
md_result_file
);
}
}
...
@@ -2640,7 +2640,7 @@ static void dump_table(char *table, char *db)
...
@@ -2640,7 +2640,7 @@ static void dump_table(char *table, char *db)
fputs
(
insert_pat
.
str
,
md_result_file
);
fputs
(
insert_pat
.
str
,
md_result_file
);
fputs
(
extended_row
.
str
,
md_result_file
);
fputs
(
extended_row
.
str
,
md_result_file
);
total_length
=
row_length
+
init_length
;
total_length
=
row_length
+
init_length
;
}
}
check_io
(
md_result_file
);
check_io
(
md_result_file
);
}
}
...
@@ -2705,15 +2705,15 @@ err:
...
@@ -2705,15 +2705,15 @@ err:
static
char
*
getTableName
(
int
reset
)
static
char
*
getTableName
(
int
reset
)
{
{
static
MYSQL_RES
*
res
=
NULL
;
static
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
if
(
!
res
)
if
(
!
res
)
{
{
if
(
!
(
res
=
mysql_list_tables
(
mysql
,
NullS
)))
if
(
!
(
res
=
mysql_list_tables
(
mysql
,
NullS
)))
return
(
NULL
);
return
(
NULL
);
}
}
if
((
row
=
mysql_fetch_row
(
res
)))
if
((
row
=
mysql_fetch_row
(
res
)))
return
((
char
*
)
row
[
0
]);
return
((
char
*
)
row
[
0
]);
if
(
reset
)
if
(
reset
)
...
@@ -2721,7 +2721,7 @@ static char *getTableName(int reset)
...
@@ -2721,7 +2721,7 @@ static char *getTableName(int reset)
else
else
{
{
mysql_free_result
(
res
);
mysql_free_result
(
res
);
res
=
NULL
;
res
=
NULL
;
}
}
return
(
NULL
);
return
(
NULL
);
}
/* getTableName */
}
/* getTableName */
...
@@ -2859,7 +2859,7 @@ static int dump_all_databases()
...
@@ -2859,7 +2859,7 @@ static int dump_all_databases()
if
(
mysql_query_with_error_report
(
mysql
,
&
tableres
,
"SHOW DATABASES"
))
if
(
mysql_query_with_error_report
(
mysql
,
&
tableres
,
"SHOW DATABASES"
))
return
1
;
return
1
;
while
((
row
=
mysql_fetch_row
(
tableres
)))
while
((
row
=
mysql_fetch_row
(
tableres
)))
{
{
if
(
dump_all_tables_in_db
(
row
[
0
]))
if
(
dump_all_tables_in_db
(
row
[
0
]))
result
=
1
;
result
=
1
;
...
@@ -2867,13 +2867,13 @@ static int dump_all_databases()
...
@@ -2867,13 +2867,13 @@ static int dump_all_databases()
if
(
seen_views
)
if
(
seen_views
)
{
{
if
(
mysql_query
(
mysql
,
"SHOW DATABASES"
)
||
if
(
mysql_query
(
mysql
,
"SHOW DATABASES"
)
||
!
(
tableres
=
mysql_store_result
(
mysql
)))
!
(
tableres
=
mysql_store_result
(
mysql
)))
{
{
my_printf_error
(
0
,
"Error: Couldn't execute 'SHOW DATABASES': %s"
,
my_printf_error
(
0
,
"Error: Couldn't execute 'SHOW DATABASES': %s"
,
MYF
(
0
),
mysql_error
(
mysql
));
MYF
(
0
),
mysql_error
(
mysql
));
return
1
;
return
1
;
}
}
while
((
row
=
mysql_fetch_row
(
tableres
)))
while
((
row
=
mysql_fetch_row
(
tableres
)))
{
{
if
(
dump_all_views_in_db
(
row
[
0
]))
if
(
dump_all_views_in_db
(
row
[
0
]))
result
=
1
;
result
=
1
;
...
@@ -2940,7 +2940,7 @@ static int init_dumping(char *database)
...
@@ -2940,7 +2940,7 @@ static int init_dumping(char *database)
"SHOW CREATE DATABASE IF NOT EXISTS %s"
,
"SHOW CREATE DATABASE IF NOT EXISTS %s"
,
qdatabase
);
qdatabase
);
if
(
mysql_query
(
mysql
,
qbuf
)
||
!
(
dbinfo
=
mysql_store_result
(
mysql
)))
if
(
mysql_query
(
mysql
,
qbuf
)
||
!
(
dbinfo
=
mysql_store_result
(
mysql
)))
{
{
/* Old server version, dump generic CREATE DATABASE */
/* Old server version, dump generic CREATE DATABASE */
if
(
opt_drop_database
)
if
(
opt_drop_database
)
...
@@ -2957,7 +2957,7 @@ static int init_dumping(char *database)
...
@@ -2957,7 +2957,7 @@ static int init_dumping(char *database)
fprintf
(
md_result_file
,
fprintf
(
md_result_file
,
"
\n
/*!40000 DROP DATABASE IF EXISTS %s*/;
\n
"
,
"
\n
/*!40000 DROP DATABASE IF EXISTS %s*/;
\n
"
,
qdatabase
);
qdatabase
);
row
=
mysql_fetch_row
(
dbinfo
);
row
=
mysql_fetch_row
(
dbinfo
);
if
(
row
[
1
])
if
(
row
[
1
])
{
{
fprintf
(
md_result_file
,
"
\n
%s;
\n
"
,
row
[
1
]);
fprintf
(
md_result_file
,
"
\n
%s;
\n
"
,
row
[
1
]);
...
@@ -3289,7 +3289,7 @@ static int do_show_master_status(MYSQL *mysql_con)
...
@@ -3289,7 +3289,7 @@ static int do_show_master_status(MYSQL *mysql_con)
}
}
else
else
{
{
row
=
mysql_fetch_row
(
master
);
row
=
mysql_fetch_row
(
master
);
if
(
row
&&
row
[
0
]
&&
row
[
1
])
if
(
row
&&
row
[
0
]
&&
row
[
1
])
{
{
/* SHOW MASTER STATUS reports file and position */
/* SHOW MASTER STATUS reports file and position */
...
@@ -3416,7 +3416,7 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
...
@@ -3416,7 +3416,7 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
MYSQL_FIELD
*
field
;
MYSQL_FIELD
*
field
;
mysql_field_seek
(
result
,
0
);
mysql_field_seek
(
result
,
0
);
for
(
;
(
field
=
mysql_fetch_field
(
result
))
;
row
++
)
for
(
;
(
field
=
mysql_fetch_field
(
result
))
;
row
++
)
{
{
if
(
!
strcmp
(
field
->
name
,
name
))
if
(
!
strcmp
(
field
->
name
,
name
))
{
{
...
@@ -3544,17 +3544,19 @@ char check_if_ignore_table(const char *table_name, char *table_type)
...
@@ -3544,17 +3544,19 @@ char check_if_ignore_table(const char *table_name, char *table_type)
static
char
*
primary_key_fields
(
const
char
*
table_name
)
static
char
*
primary_key_fields
(
const
char
*
table_name
)
{
{
MYSQL_RES
*
res
=
NULL
;
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
/* SHOW KEYS FROM + table name * 2 (escaped) + 2 quotes + \0 */
/* SHOW KEYS FROM + table name * 2 (escaped) + 2 quotes + \0 */
char
show_keys_buff
[
15
+
NAME_LEN
*
2
+
3
];
char
show_keys_buff
[
15
+
NAME_LEN
*
2
+
3
];
uint
result_length
=
0
;
uint
result_length
=
0
;
char
*
result
=
0
;
char
*
result
=
0
;
char
buff
[
NAME_LEN
*
2
+
3
];
char
*
quoted_field
;
my_snprintf
(
show_keys_buff
,
sizeof
(
show_keys_buff
),
my_snprintf
(
show_keys_buff
,
sizeof
(
show_keys_buff
),
"SHOW KEYS FROM %s"
,
table_name
);
"SHOW KEYS FROM %s"
,
table_name
);
if
(
mysql_query
(
mysql
,
show_keys_buff
)
||
if
(
mysql_query
(
mysql
,
show_keys_buff
)
||
!
(
res
=
mysql_store_result
(
mysql
)))
!
(
res
=
mysql_store_result
(
mysql
)))
{
{
fprintf
(
stderr
,
"Warning: Couldn't read keys from table %s;"
fprintf
(
stderr
,
"Warning: Couldn't read keys from table %s;"
" records are NOT sorted (%s)
\n
"
,
" records are NOT sorted (%s)
\n
"
,
...
@@ -3569,12 +3571,14 @@ static char *primary_key_fields(const char *table_name)
...
@@ -3569,12 +3571,14 @@ static char *primary_key_fields(const char *table_name)
* row, and UNIQUE keys come before others. So we only need to check
* row, and UNIQUE keys come before others. So we only need to check
* the first key, not all keys.
* the first key, not all keys.
*/
*/
if
((
row
=
mysql_fetch_row
(
res
))
&&
atoi
(
row
[
1
])
==
0
)
if
((
row
=
mysql_fetch_row
(
res
))
&&
atoi
(
row
[
1
])
==
0
)
{
{
/* Key is unique */
/* Key is unique */
do
do
result_length
+=
strlen
(
row
[
4
])
+
1
;
/* + 1 for ',' or \0 */
{
while
((
row
=
mysql_fetch_row
(
res
))
&&
atoi
(
row
[
3
])
>
1
);
quoted_field
=
quote_name
(
row
[
4
],
buff
,
0
);
result_length
+=
strlen
(
quoted_field
)
+
1
;
/* + 1 for ',' or \0 */
}
while
((
row
=
mysql_fetch_row
(
res
))
&&
atoi
(
row
[
3
])
>
1
);
}
}
/* Build the ORDER BY clause result */
/* Build the ORDER BY clause result */
...
@@ -3582,17 +3586,21 @@ static char *primary_key_fields(const char *table_name)
...
@@ -3582,17 +3586,21 @@ static char *primary_key_fields(const char *table_name)
{
{
char
*
end
;
char
*
end
;
/* result (terminating \0 is already in result_length) */
/* result (terminating \0 is already in result_length) */
result
=
my_malloc
(
result_length
+
10
,
MYF
(
MY_WME
));
result
=
my_malloc
(
result_length
+
10
,
MYF
(
MY_WME
));
if
(
!
result
)
if
(
!
result
)
{
{
fprintf
(
stderr
,
"Error: Not enough memory to store ORDER BY clause
\n
"
);
fprintf
(
stderr
,
"Error: Not enough memory to store ORDER BY clause
\n
"
);
goto
cleanup
;
goto
cleanup
;
}
}
mysql_data_seek
(
res
,
0
);
mysql_data_seek
(
res
,
0
);
row
=
mysql_fetch_row
(
res
);
row
=
mysql_fetch_row
(
res
);
end
=
strmov
(
result
,
row
[
4
]);
quoted_field
=
quote_name
(
row
[
4
],
buff
,
0
);
while
((
row
=
mysql_fetch_row
(
res
))
&&
atoi
(
row
[
3
])
>
1
)
end
=
strmov
(
result
,
quoted_field
);
end
=
strxmov
(
end
,
","
,
row
[
4
],
NullS
);
while
((
row
=
mysql_fetch_row
(
res
))
&&
atoi
(
row
[
3
])
>
1
)
{
quoted_field
=
quote_name
(
row
[
4
],
buff
,
0
);
end
=
strxmov
(
end
,
","
,
quoted_field
,
NullS
);
}
}
}
cleanup:
cleanup:
...
@@ -3660,7 +3668,7 @@ static my_bool get_view_structure(char *table, char* db)
...
@@ -3660,7 +3668,7 @@ static my_bool get_view_structure(char *table, char* db)
char
table_buff
[
NAME_LEN
*
2
+
3
];
char
table_buff
[
NAME_LEN
*
2
+
3
];
char
table_buff2
[
NAME_LEN
*
2
+
3
];
char
table_buff2
[
NAME_LEN
*
2
+
3
];
char
query
[
QUERY_LENGTH
];
char
query
[
QUERY_LENGTH
];
FILE
*
sql_file
=
md_result_file
;
FILE
*
sql_file
=
md_result_file
;
DBUG_ENTER
(
"get_view_structure"
);
DBUG_ENTER
(
"get_view_structure"
);
if
(
opt_no_create_info
)
/* Don't write table creation info */
if
(
opt_no_create_info
)
/* Don't write table creation info */
...
...
mysql-test/r/mysqldump.result
View file @
a1c70022
...
@@ -2925,6 +2925,131 @@ mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SU
...
@@ -2925,6 +2925,131 @@ mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SU
grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
drop table t1;
drop table t1;
drop user mysqltest_1@localhost;
drop user mysqltest_1@localhost;
/*!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 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_tables` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_tables`;
DROP TABLE IF EXISTS `basetable`;
CREATE TABLE `basetable` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`tag` varchar(64) default NULL,
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `basetable` WRITE;
/*!40000 ALTER TABLE `basetable` DISABLE KEYS */;
/*!40000 ALTER TABLE `basetable` ENABLE KEYS */;
UNLOCK TABLES;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_views` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_views`;
DROP TABLE IF EXISTS `nasishnasifu`;
/*!50001 DROP VIEW IF EXISTS `nasishnasifu`*/;
/*!50001 CREATE TABLE `nasishnasifu` (
`id` bigint(20) unsigned
) */;
/*!50001 DROP TABLE IF EXISTS `nasishnasifu`*/;
/*!50001 DROP VIEW IF EXISTS `nasishnasifu`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `mysqldump_views`.`nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
/*!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 nasishnasifu;
drop database mysqldump_views;
drop table mysqldump_tables.basetable;
drop database mysqldump_tables;
USE test;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a b` INT,
`c"d` INT,
`e``f` INT,
PRIMARY KEY (`a b`, `c"d`, `e``f`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
insert into t1 values (0815, 4711, 2006);
/*!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,ANSI' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS "t1";
CREATE TABLE "t1" (
"a b" int(11) NOT NULL default '0',
"c""d" int(11) NOT NULL default '0',
"e`f" int(11) NOT NULL default '0',
PRIMARY KEY ("a b","c""d","e`f")
);
LOCK TABLES "t1" WRITE;
/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
INSERT INTO "t1" VALUES (815,4711,2006);
/*!40000 ALTER TABLE "t1" ENABLE KEYS */;
UNLOCK TABLES;
/*!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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!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 */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a b` int(11) NOT NULL default '0',
`c"d` int(11) NOT NULL default '0',
`e``f` int(11) NOT NULL default '0',
PRIMARY KEY (`a b`,`c"d`,`e``f`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (815,4711,2006);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
/*!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 TABLE `t1`;
End of 5.0 tests
End of 5.0 tests
create table t1 (a text , b text);
create table t1 (a text , b text);
create table t2 (a text , b text);
create table t2 (a text , b text);
...
...
mysql-test/t/mysqldump.test
View file @
a1c70022
...
@@ -1281,6 +1281,7 @@ use mysqldump_dbb;
...
@@ -1281,6 +1281,7 @@ use mysqldump_dbb;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
;
drop
table
t1
;
drop
database
mysqldump_dbb
;
drop
database
mysqldump_dbb
;
#
#
# Bug#21215 mysqldump creating incomplete backups without warning
# Bug#21215 mysqldump creating incomplete backups without warning
#
#
...
@@ -1326,6 +1327,25 @@ grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
...
@@ -1326,6 +1327,25 @@ grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
drop
table
t1
;
drop
table
t1
;
drop
user
mysqltest_1
@
localhost
;
drop
user
mysqltest_1
@
localhost
;
--
exec
$MYSQL_DUMP
--
skip
-
comments
--
databases
mysqldump_tables
mysqldump_views
;
#
# BUG#13926: --order-by-primary fails if PKEY contains quote character
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
`t1`
;
CREATE
TABLE
`t1`
(
`a b`
INT
,
`c"d`
INT
,
`e``f`
INT
,
PRIMARY
KEY
(
`a b`
,
`c"d`
,
`e``f`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
latin1
;
insert
into
t1
values
(
0815
,
4711
,
2006
);
--
exec
$MYSQL_DUMP
--
skip
-
comments
--
compatible
=
ansi
--
order
-
by
-
primary
test
t1
--
exec
$MYSQL_DUMP
--
skip
-
comments
--
order
-
by
-
primary
test
t1
DROP
TABLE
`t1`
;
--
enable_warnings
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
#
#
...
...
sql/sql_yacc.yy
View file @
a1c70022
...
@@ -8744,6 +8744,9 @@ load: LOAD DATA_SYM
...
@@ -8744,6 +8744,9 @@ load: LOAD DATA_SYM
YYABORT;
YYABORT;
}
}
lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
WARN_DEPRECATED("LOAD TABLE FROM MASTER",
"mysqldump or future "
"BACKUP/RESTORE DATABASE facility");
if (!Select->add_table_to_list(YYTHD, $3, NULL, TL_OPTION_UPDATING))
if (!Select->add_table_to_list(YYTHD, $3, NULL, TL_OPTION_UPDATING))
YYABORT;
YYABORT;
};
};
...
@@ -8782,6 +8785,9 @@ load_data:
...
@@ -8782,6 +8785,9 @@ load_data:
FROM MASTER_SYM
FROM MASTER_SYM
{
{
Lex->sql_command = SQLCOM_LOAD_MASTER_DATA;
Lex->sql_command = SQLCOM_LOAD_MASTER_DATA;
WARN_DEPRECATED("LOAD DATA FROM MASTER",
"mysqldump or future "
"BACKUP/RESTORE DATABASE facility");
};
};
opt_local:
opt_local:
...
...
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