Skip to content

Commit 89570bf

Browse files
author
monty@nosik.monty.fi
committed
Merge mysql.com:/home/my/mysql-5.0
into mysql.com:/home/my/mysql-5.1
2 parents 38a92ca + 306b871 commit 89570bf

File tree

166 files changed

+974
-965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+974
-965
lines changed

.bzrignore

+1
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ mysql-test/r/*.err
12521252
mysql-test/r/*.log
12531253
mysql-test/r/*.out
12541254
mysql-test/r/*.reject
1255+
mysql-test/r/*.warnings
12551256
mysql-test/r/alter_table.err
12561257
mysql-test/r/archive.err
12571258
mysql-test/r/backup.log

client/mysqlbinlog.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ could be out of memory");
11401140
}
11411141
if (len < 8 && net->read_pos[0] == 254)
11421142
break; // end of data
1143-
DBUG_PRINT("info",( "len= %u, net->read_pos[5] = %d\n",
1143+
DBUG_PRINT("info",( "len: %lu, net->read_pos[5]: %d\n",
11441144
len, net->read_pos[5]));
11451145
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
11461146
len - 1, &error_msg,

client/mysqldump.c

+82-59
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
** master/autocommit code by Brian Aker <brian@tangent.org>
3131
** SSL by
3232
** Andrei Errapart <andreie@no.spam.ee>
33-
** Tõnu Samuel <tonu@please.do.not.remove.this.spam.ee>
33+
** Tõnu Samuel <tonu@please.do.not.remove.this.spam.ee>
3434
** XML by Gary Huntress <ghuntress@mediaone.net> 10/10/01, cleaned up
3535
** and adapted to mysqldump 05/11/01 by Jani Tolonen
3636
** Added --single-transaction option 06/06/2002 by Peter Zaitsev
3737
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
3838
*/
3939

40-
#define DUMP_VERSION "10.10"
40+
#define DUMP_VERSION "10.11"
4141

4242
#include <my_global.h>
4343
#include <my_sys.h>
@@ -103,14 +103,15 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
103103
opt_alltspcs=0;
104104
static ulong opt_max_allowed_packet, opt_net_buffer_length;
105105
static MYSQL mysql_connection,*mysql=0;
106-
static my_bool insert_pat_inited=0;
106+
static my_bool insert_pat_inited= 0, info_flag;
107107
static DYNAMIC_STRING insert_pat;
108108
static char *opt_password=0,*current_user=0,
109109
*current_host=0,*path=0,*fields_terminated=0,
110110
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
111111
*where=0, *order_by=0,
112112
*opt_compatible_mode_str= 0,
113113
*err_ptr= 0;
114+
static char **defaults_argv= 0;
114115
static char compatible_mode_normal_str[255];
115116
static ulong opt_compatible_mode= 0;
116117
#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
@@ -120,7 +121,7 @@ static my_string opt_mysql_unix_port=0;
120121
static int first_error=0;
121122
static DYNAMIC_STRING extended_row;
122123
#include <sslopt-vars.h>
123-
FILE *md_result_file;
124+
FILE *md_result_file= 0;
124125
#ifdef HAVE_SMEM
125126
static char *shared_memory_base_name=0;
126127
#endif
@@ -222,6 +223,8 @@ static struct my_option my_long_options[] =
222223
{"debug", '#', "Output debug log", (gptr*) &default_dbug_option,
223224
(gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
224225
#endif
226+
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag,
227+
(gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
225228
{"default-character-set", OPT_DEFAULT_CHARSET,
226229
"Set the default character set.", (gptr*) &default_charset,
227230
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -641,14 +644,6 @@ byte* get_table_key(const char *entry, uint *length,
641644
}
642645

643646

644-
void init_table_rule_hash(HASH* h)
645-
{
646-
if (hash_init(h, charset_info, 16, 0, 0,
647-
(hash_get_key) get_table_key,
648-
(hash_free_key) free_table_ent, 0))
649-
exit(EX_EOM);
650-
}
651-
652647
static my_bool
653648
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
654649
char *argument)
@@ -691,6 +686,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
691686
break;
692687
case '#':
693688
DBUG_PUSH(argument ? argument : default_dbug_option);
689+
info_flag= 1;
694690
break;
695691
#include <sslopt-case.h>
696692
case 'V': print_version(); exit(0);
@@ -731,9 +727,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
731727
fprintf(stderr, "Illegal use of option --ignore-table=<database>.<table>\n");
732728
exit(1);
733729
}
734-
if (!hash_inited(&ignore_table))
735-
init_table_rule_hash(&ignore_table);
736-
737730
if (my_hash_insert(&ignore_table, (byte*)my_strdup(argument, MYF(0))))
738731
exit(EX_EOM);
739732
break;
@@ -809,9 +802,21 @@ static int get_options(int *argc, char ***argv)
809802

810803
md_result_file= stdout;
811804
load_defaults("my",load_default_groups,argc,argv);
805+
defaults_argv= *argv;
812806

813-
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
814-
exit(ho_error);
807+
if (hash_init(&ignore_table, charset_info, 16, 0, 0,
808+
(hash_get_key) get_table_key,
809+
(hash_free_key) free_table_ent, 0))
810+
return(EX_EOM);
811+
/* Don't copy cluster internal log tables */
812+
if (my_hash_insert(&ignore_table,
813+
(byte*) my_strdup("mysql.apply_status", MYF(MY_WME))) ||
814+
my_hash_insert(&ignore_table,
815+
(byte*) my_strdup("mysql.schema", MYF(MY_WME))))
816+
return(EX_EOM);
817+
818+
if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
819+
return(ho_error);
815820

816821
*mysql_params->p_max_allowed_packet= opt_max_allowed_packet;
817822
*mysql_params->p_net_buffer_length= opt_net_buffer_length;
@@ -823,7 +828,7 @@ static int get_options(int *argc, char ***argv)
823828
{
824829
fprintf(stderr,
825830
"%s: You must use option --tab with --fields-...\n", my_progname);
826-
return(1);
831+
return(EX_USAGE);
827832
}
828833

829834
/* Ensure consistency of the set of binlog & locking options */
@@ -833,7 +838,7 @@ static int get_options(int *argc, char ***argv)
833838
{
834839
fprintf(stderr, "%s: You can't use --single-transaction and "
835840
"--lock-all-tables at the same time.\n", my_progname);
836-
return(1);
841+
return(EX_USAGE);
837842
}
838843
if (opt_master_data)
839844
opt_lock_all_tables= !opt_single_transaction;
@@ -842,14 +847,14 @@ static int get_options(int *argc, char ***argv)
842847
if (enclosed && opt_enclosed)
843848
{
844849
fprintf(stderr, "%s: You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n", my_progname);
845-
return(1);
850+
return(EX_USAGE);
846851
}
847852
if ((opt_databases || opt_alldbs) && path)
848853
{
849854
fprintf(stderr,
850855
"%s: --databases or --all-databases can't be used with --tab.\n",
851856
my_progname);
852-
return(1);
857+
return(EX_USAGE);
853858
}
854859
if (strcmp(default_charset, charset_info->csname) &&
855860
!(charset_info= get_charset_by_csname(default_charset,
@@ -858,7 +863,7 @@ static int get_options(int *argc, char ***argv)
858863
if ((*argc < 1 && !opt_alldbs) || (*argc > 0 && opt_alldbs))
859864
{
860865
short_usage();
861-
return 1;
866+
return EX_USAGE;
862867
}
863868
if (tty_password)
864869
opt_password=get_tty_password(NullS);
@@ -933,6 +938,23 @@ static FILE* open_sql_file_for_table(const char* table)
933938
}
934939

935940

941+
static void free_resources()
942+
{
943+
if (md_result_file && md_result_file != stdout)
944+
my_fclose(md_result_file, MYF(0));
945+
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
946+
if (hash_inited(&ignore_table))
947+
hash_free(&ignore_table);
948+
if (extended_insert)
949+
dynstr_free(&extended_row);
950+
if (insert_pat_inited)
951+
dynstr_free(&insert_pat);
952+
if (defaults_argv)
953+
free_defaults(defaults_argv);
954+
my_end(info_flag ? MY_CHECK_ERROR : 0);
955+
}
956+
957+
936958
static void safe_exit(int error)
937959
{
938960
if (!first_error)
@@ -941,18 +963,19 @@ static void safe_exit(int error)
941963
return;
942964
if (mysql)
943965
mysql_close(mysql);
966+
free_resources();
944967
exit(error);
945968
}
946-
/* safe_exit */
947969

948970

949971
/*
950-
** dbConnect -- connects to the host and selects DB.
972+
db_connect -- connects to the host and selects DB.
951973
*/
952-
static int dbConnect(char *host, char *user,char *passwd)
974+
975+
static int connect_to_db(char *host, char *user,char *passwd)
953976
{
954977
char buff[20+FN_REFLEN];
955-
DBUG_ENTER("dbConnect");
978+
DBUG_ENTER("connect_to_db");
956979

957980
verbose_msg("-- Connecting to %s...\n", host ? host : "localhost");
958981
mysql_init(&mysql_connection);
@@ -973,11 +996,11 @@ static int dbConnect(char *host, char *user,char *passwd)
973996
#endif
974997
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
975998
if (!(mysql= mysql_real_connect(&mysql_connection,host,user,passwd,
976-
NULL,opt_mysql_port,opt_mysql_unix_port,
977-
0)))
999+
NULL,opt_mysql_port,opt_mysql_unix_port,
1000+
0)))
9781001
{
9791002
DB_error(&mysql_connection, "when trying to connect");
980-
return 1;
1003+
DBUG_RETURN(1);
9811004
}
9821005
/*
9831006
Don't dump SET NAMES with a pre-4.1 server (bug#7997).
@@ -994,7 +1017,7 @@ static int dbConnect(char *host, char *user,char *passwd)
9941017
if (mysql_query_with_error_report(mysql, 0, buff))
9951018
{
9961019
safe_exit(EX_MYSQLERR);
997-
return 1;
1020+
DBUG_RETURN(1);
9981021
}
9991022
/*
10001023
set time_zone to UTC to allow dumping date types between servers with
@@ -1006,11 +1029,11 @@ static int dbConnect(char *host, char *user,char *passwd)
10061029
if (mysql_query_with_error_report(mysql, 0, buff))
10071030
{
10081031
safe_exit(EX_MYSQLERR);
1009-
return 1;
1032+
DBUG_RETURN(1);
10101033
}
10111034
}
1012-
return 0;
1013-
} /* dbConnect */
1035+
DBUG_RETURN(0);
1036+
} /* connect_to_db */
10141037

10151038

10161039
/*
@@ -1659,7 +1682,11 @@ static uint get_table_structure(char *table, char *db, char *table_type,
16591682
{
16601683
complete_insert= opt_complete_insert;
16611684
if (!insert_pat_inited)
1662-
insert_pat_inited= init_dynamic_string(&insert_pat, "", 1024, 1024);
1685+
{
1686+
insert_pat_inited= 1;
1687+
if (init_dynamic_string(&insert_pat, "", 1024, 1024))
1688+
safe_exit(EX_MYSQLERR);
1689+
}
16631690
else
16641691
dynstr_set(&insert_pat, "");
16651692
}
@@ -2134,7 +2161,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
21342161
21352162
*/
21362163

2137-
static void dump_triggers_for_table (char *table, char *db)
2164+
static void dump_triggers_for_table(char *table, char *db)
21382165
{
21392166
char *result_table;
21402167
char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
@@ -2980,6 +3007,8 @@ static int dump_databases(char **db_names)
29803007
{
29813008
int result=0;
29823009
char **db;
3010+
DBUG_ENTER("dump_databases");
3011+
29833012
for (db= db_names ; *db ; db++)
29843013
{
29853014
if (dump_all_tables_in_db(*db))
@@ -2993,7 +3022,7 @@ static int dump_databases(char **db_names)
29933022
result=1;
29943023
}
29953024
}
2996-
return result;
3025+
DBUG_RETURN(result);
29973026
} /* dump_databases */
29983027

29993028

@@ -3008,7 +3037,7 @@ RETURN VALUES
30083037
0 Success.
30093038
1 Failure.
30103039
*/
3011-
int init_dumping_views(char *qdatabase)
3040+
int init_dumping_views(char *qdatabase __attribute__((unused)))
30123041
{
30133042
return 0;
30143043
} /* init_dumping_views */
@@ -3105,12 +3134,11 @@ static int init_dumping(char *database, int init_func(char*))
31053134
} /* init_dumping */
31063135

31073136

3137+
/* Return 1 if we should copy the table */
3138+
31083139
my_bool include_table(byte* hash_key, uint len)
31093140
{
3110-
if (hash_search(&ignore_table, (byte*) hash_key, len))
3111-
return FALSE;
3112-
3113-
return TRUE;
3141+
return !hash_search(&ignore_table, (byte*) hash_key, len);
31143142
}
31153143

31163144

@@ -3119,10 +3147,10 @@ static int dump_all_tables_in_db(char *database)
31193147
char *table;
31203148
uint numrows;
31213149
char table_buff[NAME_LEN*2+3];
3122-
31233150
char hash_key[2*NAME_LEN+2]; /* "db.tablename" */
31243151
char *afterdot;
31253152
int using_mysql_db= my_strcasecmp(&my_charset_latin1, database, "mysql");
3153+
DBUG_ENTER("dump_all_tables_in_db");
31263154

31273155
afterdot= strmov(hash_key, database);
31283156
*afterdot++= '.';
@@ -3558,7 +3586,6 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
35583586

35593587

35603588
/*
3561-
35623589
SYNOPSIS
35633590
35643591
Check if we the table is one of the table types that should be ignored:
@@ -3598,8 +3625,8 @@ char check_if_ignore_table(const char *table_name, char *table_type)
35983625
{
35993626
if (mysql_errno(mysql) != ER_PARSE_ERROR)
36003627
{ /* If old MySQL version */
3601-
verbose_msg("-- Warning: Couldn't get status information for " \
3602-
"table %s (%s)\n", table_name,mysql_error(mysql));
3628+
verbose_msg("-- Warning: Couldn't get status information for "
3629+
"table %s (%s)\n", table_name, mysql_error(mysql));
36033630
DBUG_RETURN(result); /* assume table is ok */
36043631
}
36053632
}
@@ -3954,19 +3981,24 @@ static my_bool get_view_structure(char *table, char* db)
39543981

39553982
int main(int argc, char **argv)
39563983
{
3984+
int exit_code;
39573985
MY_INIT("mysqldump");
39583986

39593987
compatible_mode_normal_str[0]= 0;
39603988
default_charset= (char *)mysql_universal_client_charset;
39613989
bzero((char*) &ignore_table, sizeof(ignore_table));
39623990

3963-
if (get_options(&argc, &argv))
3991+
exit_code= get_options(&argc, &argv);
3992+
if (exit_code)
39643993
{
3965-
my_end(0);
3966-
exit(EX_USAGE);
3994+
free_resources(0);
3995+
exit(exit_code);
39673996
}
3968-
if (dbConnect(current_host, current_user, opt_password))
3997+
if (connect_to_db(current_host, current_user, opt_password))
3998+
{
3999+
free_resources(0);
39694000
exit(EX_MYSQLERR);
4001+
}
39704002
if (!path)
39714003
write_header(md_result_file, *argv);
39724004

@@ -4016,15 +4048,6 @@ int main(int argc, char **argv)
40164048
dbDisconnect(current_host);
40174049
if (!path)
40184050
write_footer(md_result_file);
4019-
if (md_result_file != stdout)
4020-
my_fclose(md_result_file, MYF(0));
4021-
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
4022-
if (hash_inited(&ignore_table))
4023-
hash_free(&ignore_table);
4024-
if (extended_insert)
4025-
dynstr_free(&extended_row);
4026-
if (insert_pat_inited)
4027-
dynstr_free(&insert_pat);
4028-
my_end(0);
4051+
free_resources();
40294052
return(first_error);
40304053
} /* main */

0 commit comments

Comments
 (0)