weave merge mysql-5.5->mysql-5.5-security

This commit is contained in:
Georgi Kodinov 2012-01-12 16:44:37 +02:00
commit b8cbc736d0
59 changed files with 1632 additions and 456 deletions

View file

@ -243,7 +243,6 @@ get_one_option(int optid, const struct my_option *opt,
switch (optid) {
case '?':
puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
printf("%s Ver %s Distrib %s, for %s (%s)\n",
my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));

View file

@ -77,6 +77,9 @@
/* Size of buffer for dump's select query */
#define QUERY_LENGTH 1536
/* Size of comment buffer. */
#define COMMENT_LENGTH 2048
/* ignore table flags */
#define IGNORE_NONE 0x00 /* no ignore */
#define IGNORE_DATA 0x01 /* don't dump data for this table */
@ -105,7 +108,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1,
opt_slave_apply= 0,
opt_include_master_host_port= 0,
opt_events= 0,
opt_events= 0, opt_comments_used= 0,
opt_alltspcs=0, opt_notspcs= 0;
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
@ -539,6 +542,8 @@ static int dump_all_tablespaces();
static int dump_tablespaces_for_tables(char *db, char **table_names, int tables);
static int dump_tablespaces_for_databases(char** databases);
static int dump_tablespaces(char* ts_where);
static void print_comment(FILE *sql_file, my_bool is_error, const char *format,
...);
/*
@ -562,6 +567,8 @@ static void verbose_msg(const char *fmt, ...)
vfprintf(stderr, fmt, args);
va_end(args);
fflush(stderr);
DBUG_VOID_RETURN;
}
@ -631,19 +638,19 @@ static void write_header(FILE *sql_file, char *db_name)
}
else if (!opt_compact)
{
if (opt_comments)
{
fprintf(sql_file,
"-- MySQL dump %s Distrib %s, for %s (%s)\n--\n",
DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
fprintf(sql_file, "-- Host: %s Database: %s\n",
current_host ? current_host : "localhost", db_name ? db_name :
"");
fputs("-- ------------------------------------------------------\n",
sql_file);
fprintf(sql_file, "-- Server version\t%s\n",
mysql_get_server_info(&mysql_connection));
}
print_comment(sql_file, 0,
"-- MySQL dump %s Distrib %s, for %s (%s)\n--\n",
DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE,
MACHINE_TYPE);
print_comment(sql_file, 0, "-- Host: %s Database: %s\n",
current_host ? current_host : "localhost",
db_name ? db_name : "");
print_comment(sql_file, 0,
"-- ------------------------------------------------------\n"
);
print_comment(sql_file, 0, "-- Server version\t%s\n",
mysql_get_server_info(&mysql_connection));
if (opt_set_charset)
fprintf(sql_file,
"\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"
@ -701,18 +708,16 @@ static void write_footer(FILE *sql_file)
fprintf(sql_file,
"/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n");
fputs("\n", sql_file);
if (opt_comments)
if (opt_dump_date)
{
if (opt_dump_date)
{
char time_str[20];
get_date(time_str, GETDATE_DATE_TIME, 0);
fprintf(sql_file, "-- Dump completed on %s\n",
time_str);
}
else
fprintf(sql_file, "-- Dump completed\n");
char time_str[20];
get_date(time_str, GETDATE_DATE_TIME, 0);
print_comment(sql_file, 0, "-- Dump completed on %s\n", time_str);
}
else
print_comment(sql_file, 0, "-- Dump completed\n");
check_io(sql_file);
}
} /* write_footer */
@ -786,6 +791,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
extended_insert= opt_drop= opt_lock=
opt_disable_keys= opt_autocommit= opt_create_db= 0;
break;
case 'i':
opt_comments_used= 1;
break;
case 'I':
case '?':
usage();
@ -807,11 +815,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_disable_keys= lock_tables= opt_set_charset= 0;
break;
case (int) OPT_COMPACT:
if (opt_compact)
{
opt_comments= opt_drop= opt_disable_keys= opt_lock= 0;
opt_set_charset= 0;
}
if (opt_compact)
{
opt_comments= opt_drop= opt_disable_keys= opt_lock= 0;
opt_set_charset= 0;
}
break;
case (int) OPT_TABLES:
opt_databases=0;
break;
@ -1635,20 +1644,20 @@ static char *quote_for_like(const char *name, char *buff)
}
/*
/**
Quote and print a string.
SYNOPSIS
print_quoted_xml()
xml_file - output file
str - string to print
len - its length
@param xml_file - Output file.
@param str - String to print.
@param len - Its length.
@param is_attribute_name - A check for attribute name or value.
DESCRIPTION
@description
Quote '<' '>' '&' '\"' chars and print a string to the xml_file.
*/
static void print_quoted_xml(FILE *xml_file, const char *str, ulong len)
static void print_quoted_xml(FILE *xml_file, const char *str, ulong len,
my_bool is_attribute_name)
{
const char *end;
@ -1667,6 +1676,14 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len)
case '\"':
fputs("&quot;", xml_file);
break;
case ' ':
/* Attribute names cannot contain spaces. */
if (is_attribute_name)
{
fputs("_", xml_file);
break;
}
/* fall through */
default:
fputc(*str, xml_file);
break;
@ -1727,7 +1744,7 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg,
fputs(attribute_name, xml_file);
fputc('\"', xml_file);
print_quoted_xml(xml_file, attribute_value, strlen(attribute_value));
print_quoted_xml(xml_file, attribute_value, strlen(attribute_value), 0);
fputc('\"', xml_file);
attribute_name= va_arg(arg_list, char *);
@ -1767,13 +1784,52 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg,
fputs("<", xml_file);
fputs(stag_atr, xml_file);
fputs("\"", xml_file);
print_quoted_xml(xml_file, sval, strlen(sval));
print_quoted_xml(xml_file, sval, strlen(sval), 0);
fputs("\" xsi:nil=\"true\" />", xml_file);
fputs(line_end, xml_file);
check_io(xml_file);
}
/**
Print xml CDATA section.
@param xml_file - output file
@param str - string to print
@param len - length of the string
@note
This function also takes care of the presence of '[[>'
string in the str. If found, the CDATA section is broken
into two CDATA sections, <![CDATA[]]]]> and <![CDATA[>]].
*/
static void print_xml_cdata(FILE *xml_file, const char *str, ulong len)
{
const char *end;
fputs("<![CDATA[\n", xml_file);
for (end= str + len; str != end; str++)
{
switch(*str) {
case ']':
if ((*(str + 1) == ']') && (*(str + 2) =='>'))
{
fputs("]]]]><![CDATA[>", xml_file);
str += 2;
continue;
}
/* fall through */
default:
fputc(*str, xml_file);
break;
}
}
fputs("\n]]>\n", xml_file);
check_io(xml_file);
}
/*
Print xml tag with many attributes.
@ -1783,6 +1839,7 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg,
row_name - xml tag name
tableRes - query result
row - result row
str_create - create statement header string
DESCRIPTION
Print tag with many attribute to the xml_file. Format is:
@ -1792,9 +1849,13 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg,
*/
static void print_xml_row(FILE *xml_file, const char *row_name,
MYSQL_RES *tableRes, MYSQL_ROW *row)
MYSQL_RES *tableRes, MYSQL_ROW *row,
const char *str_create)
{
uint i;
my_bool body_found= 0;
char *create_stmt_ptr;
ulong create_stmt_len= 0;
MYSQL_FIELD *field;
ulong *lengths= mysql_fetch_lengths(tableRes);
@ -1805,19 +1866,109 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
{
if ((*row)[i])
{
fputc(' ', xml_file);
print_quoted_xml(xml_file, field->name, field->name_length);
fputs("=\"", xml_file);
print_quoted_xml(xml_file, (*row)[i], lengths[i]);
fputc('"', xml_file);
check_io(xml_file);
/* For 'create' statements, dump using CDATA. */
if ((str_create) && (strcmp(str_create, field->name) == 0))
{
create_stmt_ptr= (*row)[i];
create_stmt_len= lengths[i];
body_found= 1;
}
else
{
fputc(' ', xml_file);
print_quoted_xml(xml_file, field->name, field->name_length, 1);
fputs("=\"", xml_file);
print_quoted_xml(xml_file, (*row)[i], lengths[i], 0);
fputc('"', xml_file);
check_io(xml_file);
}
}
}
fputs(" />\n", xml_file);
if (create_stmt_len)
{
DBUG_ASSERT(body_found);
fputs(">\n", xml_file);
print_xml_cdata(xml_file, create_stmt_ptr, create_stmt_len);
fprintf(xml_file, "\t\t</%s>\n", row_name);
}
else
fputs(" />\n", xml_file);
check_io(xml_file);
}
/**
Print xml comments.
@param xml_file - output file
@param len - length of comment message
@param comment_string - comment message
@description
Print the comment message in the format:
"<!-- \n comment string \n -->\n"
@note
Any occurrence of continuous hyphens will be
squeezed to a single hyphen.
*/
static void print_xml_comment(FILE *xml_file, ulong len,
const char *comment_string)
{
const char* end;
fputs("<!-- ", xml_file);
for (end= comment_string + len; comment_string != end; comment_string++)
{
/*
The string "--" (double-hyphen) MUST NOT occur within xml comments.
*/
switch (*comment_string) {
case '-':
if (*(comment_string + 1) == '-') /* Only one hyphen allowed. */
break;
default:
fputc(*comment_string, xml_file);
break;
}
}
fputs(" -->\n", xml_file);
check_io(xml_file);
}
/* A common printing function for xml and non-xml modes. */
static void print_comment(FILE *sql_file, my_bool is_error, const char *format,
...)
{
static char comment_buff[COMMENT_LENGTH];
va_list args;
/* If its an error message, print it ignoring opt_comments. */
if (!is_error && !opt_comments)
return;
va_start(args, format);
my_vsnprintf(comment_buff, COMMENT_LENGTH, format, args);
va_end(args);
if (!opt_xml)
{
fputs(comment_buff, sql_file);
check_io(sql_file);
return;
}
print_xml_comment(sql_file, strlen(comment_buff), comment_buff);
}
/*
create_delimiter
Generate a new (null-terminated) string that does not exist in query
@ -1884,8 +2035,8 @@ static uint dump_events_for_db(char *db)
mysql_real_escape_string(mysql, db_name_buff, db, strlen(db));
/* nice comments */
if (opt_comments)
fprintf(sql_file, "\n--\n-- Dumping events for database '%s'\n--\n", db);
print_comment(sql_file, 0,
"\n--\n-- Dumping events for database '%s'\n--\n", db);
/*
not using "mysql_query_with_error_report" because we may have not
@ -1900,12 +2051,17 @@ static uint dump_events_for_db(char *db)
strcpy(delimiter, ";");
if (mysql_num_rows(event_list_res) > 0)
{
fprintf(sql_file, "/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;\n");
if (opt_xml)
fputs("\t<events>\n", sql_file);
else
{
fprintf(sql_file, "/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;\n");
/* Get database collation. */
/* Get database collation. */
if (fetch_db_collation(db_name_buff, db_cl_name, sizeof (db_cl_name)))
DBUG_RETURN(1);
if (fetch_db_collation(db_name_buff, db_cl_name, sizeof (db_cl_name)))
DBUG_RETURN(1);
}
if (switch_character_set_results(mysql, "binary"))
DBUG_RETURN(1);
@ -1922,6 +2078,13 @@ static uint dump_events_for_db(char *db)
while ((row= mysql_fetch_row(event_res)) != NULL)
{
if (opt_xml)
{
print_xml_row(sql_file, "event", event_res, &row,
"Create Event");
continue;
}
/*
if the user has EXECUTE privilege he can see event names, but not the
event body!
@ -2007,8 +2170,16 @@ static uint dump_events_for_db(char *db)
mysql_free_result(event_res);
} /* end of list of events */
fprintf(sql_file, "DELIMITER ;\n");
fprintf(sql_file, "/*!50106 SET TIME_ZONE= @save_time_zone */ ;\n");
if (opt_xml)
{
fputs("\t</events>\n", sql_file);
check_io(sql_file);
}
else
{
fprintf(sql_file, "DELIMITER ;\n");
fprintf(sql_file, "/*!50106 SET TIME_ZONE= @save_time_zone */ ;\n");
}
if (switch_character_set_results(mysql, default_charset))
DBUG_RETURN(1);
@ -2062,6 +2233,7 @@ static uint dump_routines_for_db(char *db)
const char *routine_type[]= {"FUNCTION", "PROCEDURE"};
char db_name_buff[NAME_LEN*2+3], name_buff[NAME_LEN*2+3];
char *routine_name;
char *query_str;
int i;
FILE *sql_file= md_result_file;
MYSQL_RES *routine_res, *routine_list_res;
@ -2076,8 +2248,8 @@ static uint dump_routines_for_db(char *db)
mysql_real_escape_string(mysql, db_name_buff, db, strlen(db));
/* nice comments */
if (opt_comments)
fprintf(sql_file, "\n--\n-- Dumping routines for database '%s'\n--\n", db);
print_comment(sql_file, 0,
"\n--\n-- Dumping routines for database '%s'\n--\n", db);
/*
not using "mysql_query_with_error_report" because we may have not
@ -2094,6 +2266,9 @@ static uint dump_routines_for_db(char *db)
if (switch_character_set_results(mysql, "binary"))
DBUG_RETURN(1);
if (opt_xml)
fputs("\t<routines>\n", sql_file);
/* 0, retrieve and dump functions, 1, procedures */
for (i= 0; i <= 1; i++)
{
@ -2129,13 +2304,25 @@ static uint dump_routines_for_db(char *db)
row[2] ? (int) strlen(row[2]) : 0));
if (row[2] == NULL)
{
fprintf(sql_file, "\n-- insufficient privileges to %s\n", query_buff);
fprintf(sql_file, "-- does %s have permissions on mysql.proc?\n\n", current_user);
print_comment(sql_file, 1, "\n-- insufficient privileges to %s\n",
query_buff);
print_comment(sql_file, 1,
"-- does %s have permissions on mysql.proc?\n\n",
current_user);
maybe_die(EX_MYSQLERR,"%s has insufficent privileges to %s!", current_user, query_buff);
}
else if (strlen(row[2]))
{
char *query_str;
if (opt_xml)
{
if (i) // Procedures.
print_xml_row(sql_file, "routine", routine_res, &row,
"Create Procedure");
else // Functions.
print_xml_row(sql_file, "routine", routine_res, &row,
"Create Function");
continue;
}
if (opt_drop)
fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n",
routine_type[i], routine_name);
@ -2215,6 +2402,12 @@ static uint dump_routines_for_db(char *db)
mysql_free_result(routine_list_res);
} /* end of for i (0 .. 1) */
if (opt_xml)
{
fputs("\t</routines>\n", sql_file);
check_io(sql_file);
}
if (switch_character_set_results(mysql, default_charset))
DBUG_RETURN(1);
@ -2327,16 +2520,16 @@ static uint get_table_structure(char *table, char *db, char *table_type,
write_header(sql_file, db);
}
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);
print_comment(sql_file, 0,
"\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);
}
print_comment(sql_file, 0,
"\n--\n-- Table structure for table %s\n--\n\n",
result_table);
if (opt_drop)
{
/*
@ -2537,9 +2730,10 @@ static uint get_table_structure(char *table, char *db, char *table_type,
DBUG_RETURN(0);
write_header(sql_file, db);
}
if (!opt_xml && opt_comments)
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
result_table);
print_comment(sql_file, 0,
"\n--\n-- Table structure for table %s\n--\n\n",
result_table);
if (opt_drop)
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", result_table);
if (!opt_xml)
@ -2590,7 +2784,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{
if (opt_xml)
{
print_xml_row(sql_file, "field", result, &row);
print_xml_row(sql_file, "field", result, &row, NullS);
continue;
}
@ -2662,7 +2856,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{
if (opt_xml)
{
print_xml_row(sql_file, "key", result, &row);
print_xml_row(sql_file, "key", result, &row, NullS);
continue;
}
@ -2721,7 +2915,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
else
{
if (opt_xml)
print_xml_row(sql_file, "options", result, &row);
print_xml_row(sql_file, "options", result, &row, NullS);
else
{
fputs("/*!",sql_file);
@ -2765,9 +2959,19 @@ static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs,
char *quoted_table_name= quote_name(table_name, quoted_table_name_buf, 1);
char name_buff[NAME_LEN * 4 + 3];
const char *xml_msg= "\nWarning! mysqldump being run against old server "
"that does not\nsupport 'SHOW CREATE TRIGGERS' "
"statement. Skipping..\n";
DBUG_ENTER("dump_trigger_old");
if (opt_xml)
{
print_xml_comment(sql_file, strlen(xml_msg), xml_msg);
check_io(sql_file);
DBUG_VOID_RETURN;
}
fprintf(sql_file,
"--\n"
"-- WARNING: old server version. "
@ -2831,17 +3035,25 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
const char *db_cl_name)
{
MYSQL_ROW row;
char *query_str;
int db_cl_altered= FALSE;
DBUG_ENTER("dump_trigger");
while ((row= mysql_fetch_row(show_create_trigger_rs)))
{
char *query_str= cover_definer_clause(row[2], strlen(row[2]),
C_STRING_WITH_LEN("50017"),
C_STRING_WITH_LEN("50003"),
C_STRING_WITH_LEN(" TRIGGER"));
if (opt_xml)
{
print_xml_row(sql_file, "trigger", show_create_trigger_rs, &row,
"SQL Original Statement");
check_io(sql_file);
continue;
}
query_str= cover_definer_clause(row[2], strlen(row[2]),
C_STRING_WITH_LEN("50017"),
C_STRING_WITH_LEN("50003"),
C_STRING_WITH_LEN(" TRIGGER"));
if (switch_db_collation(sql_file, db_name, ";",
db_cl_name, row[5], &db_cl_altered))
DBUG_RETURN(TRUE);
@ -2929,6 +3141,13 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
/* Dump triggers. */
if (! mysql_num_rows(show_triggers_rs))
goto skip;
if (opt_xml)
print_xml_tag(sql_file, "\t", "\n", "triggers", "name=",
table_name, NullS);
while ((row= mysql_fetch_row(show_triggers_rs)))
{
@ -2961,6 +3180,13 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
}
if (opt_xml)
{
fputs("\t</triggers>\n", sql_file);
check_io(sql_file);
}
skip:
mysql_free_result(show_triggers_rs);
if (switch_character_set_results(mysql, default_charset))
@ -3209,34 +3435,24 @@ static void dump_table(char *table, char *db)
}
else
{
if (!opt_xml && opt_comments)
{
fprintf(md_result_file,"\n--\n-- Dumping data for table %s\n--\n",
result_table);
check_io(md_result_file);
}
print_comment(md_result_file, 0,
"\n--\n-- Dumping data for table %s\n--\n",
result_table);
dynstr_append_checked(&query_string, "SELECT /*!40001 SQL_NO_CACHE */ * FROM ");
dynstr_append_checked(&query_string, result_table);
if (where)
{
if (!opt_xml && opt_comments)
{
fprintf(md_result_file, "-- WHERE: %s\n", where);
check_io(md_result_file);
}
print_comment(md_result_file, 0, "-- WHERE: %s\n", where);
dynstr_append_checked(&query_string, " WHERE ");
dynstr_append_checked(&query_string, where);
}
if (order_by)
{
if (!opt_xml && opt_comments)
{
fprintf(md_result_file, "-- ORDER BY: %s\n", order_by);
check_io(md_result_file);
}
print_comment(md_result_file, 0, "-- ORDER BY: %s\n", order_by);
dynstr_append_checked(&query_string, " ORDER BY ");
dynstr_append_checked(&query_string, order_by);
}
@ -3432,7 +3648,7 @@ static void dump_table(char *table, char *db)
{
print_xml_tag(md_result_file, "\t\t", "", "field", "name=",
field->name, NullS);
print_quoted_xml(md_result_file, row[i], length);
print_quoted_xml(md_result_file, row[i], length, 0);
}
fputs("</field>\n", md_result_file);
}
@ -3736,11 +3952,9 @@ static int dump_tablespaces(char* ts_where)
first= 1;
if (first)
{
if (!opt_xml && opt_comments)
{
fprintf(md_result_file,"\n--\n-- Logfile group: %s\n--\n", row[0]);
check_io(md_result_file);
}
print_comment(md_result_file, 0, "\n--\n-- Logfile group: %s\n--\n",
row[0]);
fprintf(md_result_file, "\nCREATE");
}
else
@ -3808,11 +4022,7 @@ static int dump_tablespaces(char* ts_where)
first= 1;
if (first)
{
if (!opt_xml && opt_comments)
{
fprintf(md_result_file,"\n--\n-- Tablespace: %s\n--\n", row[0]);
check_io(md_result_file);
}
print_comment(md_result_file, 0, "\n--\n-- Tablespace: %s\n--\n", row[0]);
fprintf(md_result_file, "\nCREATE");
}
else
@ -4010,11 +4220,9 @@ static int init_dumping(char *database, int init_func(char*))
*/
char quoted_database_buf[NAME_LEN*2+3];
char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
if (opt_comments)
{
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
check_io(md_result_file);
}
print_comment(md_result_file, 0,
"\n--\n-- Current Database: %s\n--\n", qdatabase);
/* Call the view or table specific function */
init_func(qdatabase);
@ -4079,6 +4287,8 @@ static int dump_all_tables_in_db(char *database)
if (mysql_refresh(mysql, REFRESH_LOG))
DB_error(mysql, "when doing refresh");
/* We shall continue here, if --force was given */
else
verbose_msg("-- dump_all_tables_in_db : logs flushed successfully!\n");
}
while ((table= getTableName(0)))
{
@ -4088,8 +4298,7 @@ static int dump_all_tables_in_db(char *database)
dump_table(table,database);
my_free(order_by);
order_by= 0;
if (opt_dump_triggers && ! opt_xml &&
mysql_get_server_version(mysql) >= 50009)
if (opt_dump_triggers && mysql_get_server_version(mysql) >= 50009)
{
if (dump_triggers_for_table(table, database))
{
@ -4100,14 +4309,12 @@ static int dump_all_tables_in_db(char *database)
}
}
}
if (opt_events && !opt_xml &&
mysql_get_server_version(mysql) >= 50106)
if (opt_events && mysql_get_server_version(mysql) >= 50106)
{
DBUG_PRINT("info", ("Dumping events for database %s", database));
dump_events_for_db(database);
}
if (opt_routines && !opt_xml &&
mysql_get_server_version(mysql) >= 50009)
if (opt_routines && mysql_get_server_version(mysql) >= 50009)
{
DBUG_PRINT("info", ("Dumping routines for database %s", database));
dump_routines_for_db(database);
@ -4179,6 +4386,8 @@ static my_bool dump_all_views_in_db(char *database)
if (mysql_refresh(mysql, REFRESH_LOG))
DB_error(mysql, "when doing refresh");
/* We shall continue here, if --force was given */
else
verbose_msg("-- dump_all_views_in_db : logs flushed successfully!\n");
}
while ((table= getTableName(0)))
{
@ -4317,6 +4526,8 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
DB_error(mysql, "when doing refresh");
}
/* We shall countinue here, if --force was given */
else
verbose_msg("-- dump_selected_tables : logs flushed successfully!\n");
}
if (opt_xml)
print_xml_tag(md_result_file, "", "\n", "database", "name=", db, NullS);
@ -4344,15 +4555,13 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
for (pos= dump_tables; pos < end; pos++)
get_view_structure(*pos, db);
}
if (opt_events && !opt_xml &&
mysql_get_server_version(mysql) >= 50106)
if (opt_events && mysql_get_server_version(mysql) >= 50106)
{
DBUG_PRINT("info", ("Dumping events for database %s", db));
dump_events_for_db(db);
}
/* obtain dump of routines (procs/functions) */
if (opt_routines && !opt_xml &&
mysql_get_server_version(mysql) >= 50009)
if (opt_routines && mysql_get_server_version(mysql) >= 50009)
{
DBUG_PRINT("info", ("Dumping routines for database %s", db));
dump_routines_for_db(db);
@ -4387,10 +4596,9 @@ static int do_show_master_status(MYSQL *mysql_con)
if (row && row[0] && row[1])
{
/* SHOW MASTER STATUS reports file and position */
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- Position to start replication or point-in-time "
"recovery from\n--\n\n");
print_comment(md_result_file, 0,
"\n--\n-- Position to start replication or point-in-time "
"recovery from\n--\n\n");
fprintf(md_result_file,
"%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n",
comment_prefix, row[0], row[1]);
@ -4600,6 +4808,7 @@ static int purge_bin_logs_to(MYSQL *mysql_con, char* log_name)
static int start_transaction(MYSQL *mysql_con)
{
verbose_msg("-- Starting transaction...\n");
/*
We use BEGIN for old servers. --single-transaction --master-data will fail
on old servers, but that's ok as it was already silently broken (it didn't
@ -4977,12 +5186,10 @@ static my_bool get_view_structure(char *table, char* db)
write_header(sql_file, db);
}
if (!opt_xml && opt_comments)
{
fprintf(sql_file, "\n--\n-- Final view structure for view %s\n--\n\n",
result_table);
check_io(sql_file);
}
print_comment(sql_file, 0,
"\n--\n-- Final view structure for view %s\n--\n\n",
result_table);
/* Table might not exist if this view was dumped with --tab. */
fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table);
if (opt_drop)
@ -5179,6 +5386,12 @@ int main(int argc, char **argv)
exit(exit_code);
}
/*
Disable comments in xml mode if 'comments' option is not explicitly used.
*/
if (opt_xml && !opt_comments_used)
opt_comments= 0;
if (log_error_file)
{
if(!(stderror_file= freopen(log_error_file, "a+", stderr)))
@ -5199,24 +5412,39 @@ int main(int argc, char **argv)
if (opt_slave_data && do_stop_slave_sql(mysql))
goto err;
if ((opt_lock_all_tables || opt_master_data) &&
if ((opt_lock_all_tables || opt_master_data ||
(opt_single_transaction && flush_logs)) &&
do_flush_tables_read_lock(mysql))
goto err;
if (opt_single_transaction && start_transaction(mysql))
goto err;
if (opt_delete_master_logs)
/*
Flush logs before starting transaction since
this causes implicit commit starting mysql-5.5.
*/
if (opt_lock_all_tables || opt_master_data ||
(opt_single_transaction && flush_logs) ||
opt_delete_master_logs)
{
if (mysql_refresh(mysql, REFRESH_LOG) ||
get_bin_log_name(mysql, bin_log_name, sizeof(bin_log_name)))
goto err;
if (flush_logs || opt_delete_master_logs)
{
if (mysql_refresh(mysql, REFRESH_LOG))
goto err;
verbose_msg("-- main : logs flushed successfully!\n");
}
/* Not anymore! That would not be sensible. */
flush_logs= 0;
}
if (opt_lock_all_tables || opt_master_data)
if (opt_delete_master_logs)
{
if (flush_logs && mysql_refresh(mysql, REFRESH_LOG))
if (get_bin_log_name(mysql, bin_log_name, sizeof(bin_log_name)))
goto err;
flush_logs= 0; /* not anymore; that would not be sensible */
}
if (opt_single_transaction && start_transaction(mysql))
goto err;
/* Add 'STOP SLAVE to beginning of dump */
if (opt_slave_apply && add_stop_slave())
goto err;

View file

@ -45,11 +45,11 @@
* seems to actually advertise this properly, despite Unicode 3.1 having
* been around since 2001... */
/* XXXMYSQL : Added FreeBSD to bypass this check.
TODO : Verify if FreeBSD stores ISO 10646 in wchar_t. */
/* XXXMYSQL : Added FreeBSD & AIX to bypass this check.
TODO : Verify if FreeBSD & AIX stores ISO 10646 in wchar_t. */
#if !defined(__NetBSD__) && !defined(__sun) \
&& !(defined(__APPLE__) && defined(__MACH__)) \
&& !defined(__FreeBSD__)
&& !defined(__FreeBSD__) && !defined(_AIX)
#ifndef __STDC_ISO_10646__
/* In many places it is assumed that the first 127 code points are ASCII
* compatible, so ensure wchar_t indeed does ISO 10646 and not some other

View file

@ -200,7 +200,7 @@ el_set(EditLine *el, int op, ...)
ret = -1;
goto out;
}
// XXX: The two strdup's leak
/* XXX: The two strdups leak. */
ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]),
func);
ct_free_argv(wargv);

View file

@ -1978,7 +1978,7 @@ rl_callback_read_char()
} else
wbuf = NULL;
(*(void (*)(const char *))rl_linefunc)(wbuf);
//el_set(e, EL_UNBUFFERED, 1);
/*el_set(e, EL_UNBUFFERED, 1);*/
}
}

View file

@ -24,6 +24,4 @@ sys_vars.wait_timeout_func # Bug#11750645 2010-04-26 alik wai
sys_vars.ndb_log_update_as_write_basic
sys_vars.have_ndbcluster_basic
sys_vars.ndb_log_updated_only_basic
sys_vars.query_cache_size_basic_64 # Bug#11748572 - 36747: ALLOCATING A LARGE QUERY CACHE IS NOT DETERMINISTIC
sys_vars.query_cache_size_basic_32 # Bug#11748572 - 36747: ALLOCATING A LARGE QUERY CACHE IS NOT DETERMINISTIC
sys_vars.rpl_init_slave_func # Bug#12535301 2011-05-09 andrei sys_vars.rpl_init_slave_func mismatches in daily-5.5

View file

@ -55,6 +55,11 @@
# comma-separated list. Example:
#
# --let $status_items= Master_Log_File, Relay_Master_Log_File
#
# $slave_io_error_replace
# If set, one or more regex patterns for replacing variable
# text in the error message. Syntax as --replace-regex
#
--let $_show_slave_status_items=$status_items
@ -70,6 +75,7 @@ while ($_show_slave_status_items)
--let $_show_slave_status_items= `SELECT LTRIM(SUBSTRING('$_show_slave_status_items', LENGTH('$_show_slave_status_name') + 2))`
--let $_show_slave_status_value= query_get_value(SHOW SLAVE STATUS, $_show_slave_status_name, 1)
--replace_regex $slave_io_error_replace
--let $_show_slave_status_value= `SELECT REPLACE("$_show_slave_status_value", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
--echo $_show_slave_status_name = '$_show_slave_status_value'
}

View file

@ -33,6 +33,10 @@
# (e.g., temporary connection error) and does not cause the slave
# IO thread to stop.
#
# $slave_io_error_replace
# If set, one or more regex patterns for replacing variable
# text in the error message. Syntax as --replace-regex
#
# $slave_timeout
# See include/wait_for_slave_param.inc
#

View file

@ -1433,6 +1433,21 @@ NULL 1 NULL
SET storage_engine=NULL;
ERROR 42000: Variable 'storage_engine' can't be set to the value of 'NULL'
#
# BUG#13354387 - CRASH IN IN MY_DECIMAL::OPERATOR FOR VIEW AND FUNCTION UNIX_TIMESTAMP
# Part1 (5.5)
SET time_zone='+03:00';
CREATE TABLE t1 (a DATETIME NOT NULL);
INSERT INTO t1 VALUES ('2009-09-20 07:32:39.06');
INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00');
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT CAST(UNIX_TIMESTAMP(a) AS DECIMAL(25,3)) AS c1 FROM v1 ORDER BY 1;
c1
0.000
1253421159.000
DROP VIEW v1;
DROP TABLE t1;
SET time_zone=DEFAULT;
#
# Bug #59686 crash in String::copy() with time data type
#
SELECT min(timestampadd(month, 1>'', from_days('%Z')));

View file

@ -20,6 +20,8 @@ hex(a)
616263
set GLOBAL init_connect="adsfsdfsdfs";
select @a;
ERROR 08S01: Aborted connection to db: 'test' user: 'user_1' host: 'localhost' (init_connect command failed)
select @a;
Got one of the listed errors
drop table t1;
End of 4.1 tests

View file

@ -4628,6 +4628,445 @@ ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
DROP DATABASE `test-database`;
USE test;
#
# BUG#11760384 : 52792: mysqldump in XML mode does not dump routines.
#
CREATE DATABASE BUG52792;
USE BUG52792;
CREATE TABLE t1 (c1 INT, c2 VARCHAR(20));
CREATE TABLE t2 (c1 INT);
INSERT INTO t1 VALUES (1, 'aaa'), (2, 'bbb'), (3, 'ccc');
INSERT INTO t2 VALUES (1),(2),(3);
# Stored Procedures.
CREATE PROCEDURE simpleproc1 (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t1;
END//
CREATE PROCEDURE simpleproc2 (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t2;
END//
# Events.
CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792;
CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792;
# Functions.
CREATE FUNCTION `hello1` (s CHAR(20))
RETURNS CHAR(50) DETERMINISTIC
RETURN CONCAT('Hello, ' ,s ,'!');
CREATE FUNCTION `hello2` (s CHAR(20))
RETURNS CHAR(50) DETERMINISTIC
RETURN CONCAT(']]>, ' , s ,'!');
# Triggers.
CREATE TRIGGER trig1 BEFORE INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1);
END;
|
CREATE TRIGGER trig2 AFTER INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1, ']]>');
INSERT INTO t2 VALUES(2, '<![CDATA]]>');
INSERT INTO t2 VALUES(3, '<![CDATA[');
INSERT INTO t2 VALUES(4, '< > & \ " _');
END;
|
# Views
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE VIEW v2 AS SELECT * FROM t2;
# Dumping BUG52792 database in xml format.
# Running 'replace_regex on timestamp'
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="BUG52792">
<table_structure name="t1">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<field Field="c2" Type="varchar(20)" Null="YES" Key="" Extra="" Comment="" />
<options Name="t1" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="3" Avg_row_length="20" Data_length="60" Max_data_length="281474976710655" Index_length="1024" Data_free="0" Create_time="--TIME--" Update_time="--TIME--" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_data name="t1">
<row>
<field name="c1">1</field>
<field name="c2">aaa</field>
</row>
<row>
<field name="c1">2</field>
<field name="c2">bbb</field>
</row>
<row>
<field name="c1">3</field>
<field name="c2">ccc</field>
</row>
</table_data>
<table_structure name="t2">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<options Name="t2" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="3" Avg_row_length="7" Data_length="21" Max_data_length="1970324836974591" Index_length="1024" Data_free="0" Create_time="--TIME--" Update_time="--TIME--" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_data name="t2">
<row>
<field name="c1">1</field>
</row>
<row>
<field name="c1">2</field>
</row>
<row>
<field name="c1">3</field>
</row>
</table_data>
<triggers name="t2">
<trigger Trigger="trig1" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` TRIGGER trig1 BEFORE INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1);
END
]]>
</trigger>
<trigger Trigger="trig2" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` TRIGGER trig2 AFTER INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1, ']]]]><![CDATA[>');
INSERT INTO t2 VALUES(2, '<![CDATA]]]]><![CDATA[>');
INSERT INTO t2 VALUES(3, '<![CDATA[');
INSERT INTO t2 VALUES(4, '< > & \ " _');
END
]]>
</trigger>
</triggers>
<table_structure name="v1">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<field Field="c2" Type="varchar(20)" Null="YES" Key="" Extra="" Comment="" />
<options Name="v1" Comment="VIEW" />
</table_structure>
<table_structure name="v2">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<options Name="v2" Comment="VIEW" />
</table_structure>
<events>
<event Event="e1" sql_mode="" time_zone="SYSTEM" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 1 SECOND STARTS '--TIME--' ON COMPLETION NOT PRESERVE ENABLE DO DROP DATABASE BUG52792
]]>
</event>
<event Event="e2" sql_mode="" time_zone="SYSTEM" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` EVENT `e2` ON SCHEDULE EVERY 1 SECOND STARTS '--TIME--' ON COMPLETION NOT PRESERVE ENABLE DO DROP DATABASE BUG52792
]]>
</event>
</events>
<routines>
<routine Function="hello1" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` FUNCTION `hello1`(s CHAR(20)) RETURNS char(50) CHARSET latin1
DETERMINISTIC
RETURN CONCAT('Hello, ' ,s ,'!')
]]>
</routine>
<routine Function="hello2" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` FUNCTION `hello2`(s CHAR(20)) RETURNS char(50) CHARSET latin1
DETERMINISTIC
RETURN CONCAT(']]]]><![CDATA[>, ' , s ,'!')
]]>
</routine>
<routine Procedure="simpleproc1" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` PROCEDURE `simpleproc1`(OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t1;
END
]]>
</routine>
<routine Procedure="simpleproc2" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` PROCEDURE `simpleproc2`(OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t2;
END
]]>
</routine>
</routines>
</database>
</mysqldump>
# Dumping BUG52792 database in xml format with comments.
# Running 'replace_regex on timestamp'
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="BUG52792">
<!--
-
- Table structure for table `t1`
-
-->
<table_structure name="t1">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<field Field="c2" Type="varchar(20)" Null="YES" Key="" Extra="" Comment="" />
<options Name="t1" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="3" Avg_row_length="20" Data_length="60" Max_data_length="281474976710655" Index_length="1024" Data_free="0" Create_time="--TIME--" Update_time="--TIME--" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<!--
-
- Dumping data for table `t1`
-
-->
<table_data name="t1">
<row>
<field name="c1">1</field>
<field name="c2">aaa</field>
</row>
<row>
<field name="c1">2</field>
<field name="c2">bbb</field>
</row>
<row>
<field name="c1">3</field>
<field name="c2">ccc</field>
</row>
</table_data>
<!--
-
- Table structure for table `t2`
-
-->
<table_structure name="t2">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<options Name="t2" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="3" Avg_row_length="7" Data_length="21" Max_data_length="1970324836974591" Index_length="1024" Data_free="0" Create_time="--TIME--" Update_time="--TIME--" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<!--
-
- Dumping data for table `t2`
-
-->
<table_data name="t2">
<row>
<field name="c1">1</field>
</row>
<row>
<field name="c1">2</field>
</row>
<row>
<field name="c1">3</field>
</row>
</table_data>
<triggers name="t2">
<trigger Trigger="trig1" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` TRIGGER trig1 BEFORE INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1);
END
]]>
</trigger>
<trigger Trigger="trig2" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` TRIGGER trig2 AFTER INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1, ']]]]><![CDATA[>');
INSERT INTO t2 VALUES(2, '<![CDATA]]]]><![CDATA[>');
INSERT INTO t2 VALUES(3, '<![CDATA[');
INSERT INTO t2 VALUES(4, '< > & \ " _');
END
]]>
</trigger>
</triggers>
<!--
-
- Table structure for table `v1`
-
-->
<table_structure name="v1">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<field Field="c2" Type="varchar(20)" Null="YES" Key="" Extra="" Comment="" />
<options Name="v1" Comment="VIEW" />
</table_structure>
<!--
-
- Table structure for table `v2`
-
-->
<table_structure name="v2">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<options Name="v2" Comment="VIEW" />
</table_structure>
<!--
-
- Dumping events for database 'BUG52792'
-
-->
<events>
<event Event="e1" sql_mode="" time_zone="SYSTEM" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 1 SECOND STARTS '--TIME--' ON COMPLETION NOT PRESERVE ENABLE DO DROP DATABASE BUG52792
]]>
</event>
<event Event="e2" sql_mode="" time_zone="SYSTEM" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` EVENT `e2` ON SCHEDULE EVERY 1 SECOND STARTS '--TIME--' ON COMPLETION NOT PRESERVE ENABLE DO DROP DATABASE BUG52792
]]>
</event>
</events>
<!--
-
- Dumping routines for database 'BUG52792'
-
-->
<routines>
<routine Function="hello1" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` FUNCTION `hello1`(s CHAR(20)) RETURNS char(50) CHARSET latin1
DETERMINISTIC
RETURN CONCAT('Hello, ' ,s ,'!')
]]>
</routine>
<routine Function="hello2" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` FUNCTION `hello2`(s CHAR(20)) RETURNS char(50) CHARSET latin1
DETERMINISTIC
RETURN CONCAT(']]]]><![CDATA[>, ' , s ,'!')
]]>
</routine>
<routine Procedure="simpleproc1" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` PROCEDURE `simpleproc1`(OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t1;
END
]]>
</routine>
<routine Procedure="simpleproc2" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` PROCEDURE `simpleproc2`(OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t2;
END
]]>
</routine>
</routines>
</database>
</mysqldump>
# Test to check 'Insufficient privileges' error.
GRANT ALL PRIVILEGES ON BUG52792.* TO user1;
# Running 'replace_regex on timestamp'
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="BUG52792">
<table_structure name="t1">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<field Field="c2" Type="varchar(20)" Null="YES" Key="" Extra="" Comment="" />
<options Name="t1" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="3" Avg_row_length="20" Data_length="60" Max_data_length="281474976710655" Index_length="1024" Data_free="0" Create_time="--TIME--" Update_time="--TIME--" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_data name="t1">
<row>
<field name="c1">1</field>
<field name="c2">aaa</field>
</row>
<row>
<field name="c1">2</field>
<field name="c2">bbb</field>
</row>
<row>
<field name="c1">3</field>
<field name="c2">ccc</field>
</row>
</table_data>
<table_structure name="t2">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<options Name="t2" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="3" Avg_row_length="7" Data_length="21" Max_data_length="1970324836974591" Index_length="1024" Data_free="0" Create_time="--TIME--" Update_time="--TIME--" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_data name="t2">
<row>
<field name="c1">1</field>
</row>
<row>
<field name="c1">2</field>
</row>
<row>
<field name="c1">3</field>
</row>
</table_data>
<triggers name="t2">
<trigger Trigger="trig1" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` TRIGGER trig1 BEFORE INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1);
END
]]>
</trigger>
<trigger Trigger="trig2" sql_mode="" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` TRIGGER trig2 AFTER INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1, ']]]]><![CDATA[>');
INSERT INTO t2 VALUES(2, '<![CDATA]]]]><![CDATA[>');
INSERT INTO t2 VALUES(3, '<![CDATA[');
INSERT INTO t2 VALUES(4, '< > & \ " _');
END
]]>
</trigger>
</triggers>
<table_structure name="v1">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<field Field="c2" Type="varchar(20)" Null="YES" Key="" Extra="" Comment="" />
<options Name="v1" Comment="VIEW" />
</table_structure>
<table_structure name="v2">
<field Field="c1" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<options Name="v2" Comment="VIEW" />
</table_structure>
<events>
<event Event="e1" sql_mode="" time_zone="SYSTEM" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 1 SECOND STARTS '--TIME--' ON COMPLETION NOT PRESERVE ENABLE DO DROP DATABASE BUG52792
]]>
</event>
<event Event="e2" sql_mode="" time_zone="SYSTEM" character_set_client="latin1" collation_connection="latin1_swedish_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` EVENT `e2` ON SCHEDULE EVERY 1 SECOND STARTS '--TIME--' ON COMPLETION NOT PRESERVE ENABLE DO DROP DATABASE BUG52792
]]>
</event>
</events>
<routines>
<!--
- insufficient privileges to SHOW CREATE FUNCTION `hello1`
-->
<!-- - does user1 have permissions on mysql.proc?
-->
DROP USER user1;
DROP DATABASE BUG52792;
# UTF-8
CREATE DATABASE BUG52792;
USE BUG52792;
SET NAMES utf8;
CREATE FUNCTION `straße` ( c1 CHAR(20))
RETURNS CHAR(50) DETERMINISTIC
RETURN CONCAT(']]>, ', s, '!');
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="BUG52792">
<routines>
<routine Function="straße" sql_mode="" character_set_client="utf8" collation_connection="utf8_general_ci" Database_Collation="latin1_swedish_ci">
<![CDATA[
CREATE DEFINER=`root`@`localhost` FUNCTION `straße`( c1 CHAR(20)) RETURNS char(50) CHARSET latin1
DETERMINISTIC
RETURN CONCAT(']]]]><![CDATA[>, ', s, '!')
]]>
</routine>
</routines>
</database>
</mysqldump>
DROP DATABASE BUG52792;
USE test;
#
# End of 5.1 tests
#
#
@ -4662,3 +5101,107 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
#
# Bug#12809202 61854: MYSQLDUMP --SINGLE-TRANSACTION --FLUSH-LOG BREAKS
# CONSISTENCY
#
DROP DATABASE IF EXISTS b12809202_db;
CREATE DATABASE b12809202_db;
CREATE TABLE b12809202_db.t1 (c1 INT);
CREATE TABLE b12809202_db.t2 (c1 INT);
INSERT INTO b12809202_db.t1 VALUES (1), (2), (3);
INSERT INTO b12809202_db.t2 VALUES (1), (2), (3);
# Starting mysqldump with --single-transaction & --flush-log options..
# Note : In the following dump the transaction
# should start only after the logs are
# flushed, as 'flush logs' causes implicit
# commit starting 5.5.
#### Dump starts here ####
-- Connecting to localhost...
-- main : logs flushed successfully!
-- Starting transaction...
-- Retrieving table structure for table t1...
-- Sending SELECT query...
-- Retrieving rows...
--
-- Host: localhost Database: b12809202_db
-- ------------------------------------------------------
/*!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 */;
--
-- Table structure for table `t1`
--
DROP TABLE IF EXISTS `t1`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `t1`
--
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1),(2),(3);
-- Retrieving table structure for table t2...
-- Sending SELECT query...
-- Retrieving rows...
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `t2`
--
DROP TABLE IF EXISTS `t2`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`c1` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `t2`
--
LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT INTO `t2` VALUES (1),(2),(3);
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
UNLOCK TABLES;
-- Disconnecting from localhost...
/*!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 */;
-- Dump completed
#### Dump ends here ####
DROP TABLE b12809202_db.t1;
DROP TABLE b12809202_db.t2;
DROP DATABASE b12809202_db;
#
# Delete all existing binary logs.
#
RESET MASTER;

View file

@ -2772,20 +2772,23 @@ userid
drop procedure bug8116|
drop table t3|
drop procedure if exists bug6857|
create procedure bug6857(counter int)
create procedure bug6857()
begin
declare t0, t1 int;
declare plus bool default 0;
set t0 = current_time();
while counter > 0 do
set counter = counter - 1;
end while;
set t1 = current_time();
set t0 = unix_timestamp();
select sleep(1.1);
set t1 = unix_timestamp();
if t1 > t0 then
set plus = 1;
end if;
select plus;
end|
call bug6857()|
sleep(1.1)
0
plus
1
drop procedure bug6857|
drop procedure if exists bug8757|
create procedure bug8757()

View file

@ -54,13 +54,13 @@ USE test;
#
SET @old_log_warnings = @@log_warnings;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(10));
CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(15));
SET GLOBAL LOG_WARNINGS = 0;
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
INSERT INTO t1 VALUES(UUID(), 'timestamp');
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
SET GLOBAL LOG_WARNINGS = 1;
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
INSERT INTO t1 VALUES(UUID(), 'timestamp');
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
DROP TABLE t1;

View file

@ -101,16 +101,24 @@ eval USE $old_db;
--echo # Bug#46265: Can not disable warning about unsafe statements for binary logging
--echo #
let BINLOG_COUNTER1= `select CONVERT(NOW(),UNSIGNED) as timestmap from dual`;
SET @old_log_warnings = @@log_warnings;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(10));
CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(15));
SET GLOBAL LOG_WARNINGS = 0;
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
# Replacing the result file content here.
# Instead of writing $BINLOG_COUNTER1 value to result file,
# writing a fixed string timestamp to it.
--replace_result $BINLOG_COUNTER1 timestamp
eval INSERT INTO t1 VALUES(UUID(), '$BINLOG_COUNTER1');
SET GLOBAL LOG_WARNINGS = 1;
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
--replace_result $BINLOG_COUNTER1 timestamp
eval INSERT INTO t1 VALUES(UUID(), '$BINLOG_COUNTER1');
DROP TABLE t1;
SET GLOBAL log_warnings = @old_log_warnings;
@ -132,13 +140,14 @@ perl;
use strict;
my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set";
open(FILE, "$log_error") or die("Unable to open $log_error: $!\n");
my $count = () = grep(/Bug#46265/g,<FILE>);
my $binlog_counter= $ENV{'BINLOG_COUNTER1'} or die "BINLOG_COUNTER1 not set";
my $count = () = grep(/$binlog_counter/g,<FILE>);
# Grep the timestamp value from the error file.
print "Occurrences: $count\n";
close(FILE);
EOF
# bug#50192: diplaying the unsafe warning comes out to the user warning stack
-- disable_warnings
DROP TABLE IF EXISTS t1, t2;
-- enable_warnings

View file

@ -0,0 +1,25 @@
call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too");
show variables like "max_connections";
Variable_name Value
max_connections 64
show variables like "innodb_thread_concurrency";
Variable_name Value
innodb_thread_concurrency 0
show variables like "innodb_file_per_table";
Variable_name Value
innodb_file_per_table ON
drop database if exists mysqltest;
create database mysqltest;
CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB;
select count(*) from information_schema.processlist;
count(*)
33
CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB;
ERROR HY000: Can't create table 'mysqltest.testtable' (errno: 177)
select count(*) from information_schema.processlist;
count(*)
33
select count(*) from information_schema.processlist;
count(*)
33
drop database mysqltest;

View file

@ -0,0 +1 @@
--max_connections=64 --innodb_thread_concurrency=0 --innodb_file_per_table --innodb_rollback_segments=2

View file

@ -0,0 +1,103 @@
# Test for bug #12400341: INNODB CAN LEAVE ORPHAN IBD FILES AROUND
-- source include/have_innodb.inc
if (`select count(*)=0 from information_schema.global_variables where variable_name = 'INNODB_TRX_RSEG_N_SLOTS_DEBUG'`)
{
--skip Test requires InnoDB built with UNIV_DEBUG definition.
}
call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too");
--disable_query_log
set @old_innodb_trx_rseg_n_slots_debug = @@innodb_trx_rseg_n_slots_debug;
set global innodb_trx_rseg_n_slots_debug = 32;
--enable_query_log
show variables like "max_connections";
show variables like "innodb_thread_concurrency";
show variables like "innodb_file_per_table";
--disable_warnings
drop database if exists mysqltest;
--enable_warnings
create database mysqltest;
CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB;
--disable_query_log
#
# Insert in 1 transaction which needs over 1 page undo record to avoid the insert_undo cached,
# because the cached insert_undo can be reused at "CREATE TABLE" statement later.
#
START TRANSACTION;
let $c = 1024;
while ($c)
{
eval INSERT INTO mysqltest.transtable (id) VALUES ($c);
dec $c;
}
COMMIT;
let $c = 32;
while ($c)
{
# if failed at here, it might be shortage of file descriptors limit.
connect (con$c,localhost,root,,);
dec $c;
}
--enable_query_log
select count(*) from information_schema.processlist;
#
# fill the all undo slots
#
--disable_query_log
let $c = 32;
while ($c)
{
connection con$c;
START TRANSACTION;
eval UPDATE mysqltest.transtable SET val = 1 WHERE id = 33 - $c;
dec $c;
}
--enable_query_log
connection default;
--error ER_CANT_CREATE_TABLE
CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB;
select count(*) from information_schema.processlist;
--disable_query_log
let $c = 32;
while ($c)
{
connection con$c;
ROLLBACK;
dec $c;
}
--enable_query_log
connection default;
select count(*) from information_schema.processlist;
--disable_query_log
let $c = 32;
while ($c)
{
disconnect con$c;
dec $c;
}
--enable_query_log
#
# If the isolated .ibd file remained, the drop database should fail.
#
drop database mysqltest;
--disable_query_log
set global innodb_trx_rseg_n_slots_debug = @old_innodb_trx_rseg_n_slots_debug;
--enable_query_log

View file

@ -1,5 +1,6 @@
include/master-slave.inc
[connection master]
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT,
UNIQUE(b));
INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10;

View file

@ -9,6 +9,7 @@ change master to master_log_pos=MASTER_LOG_POS;
Read_Master_Log_Pos = '75'
start slave;
include/wait_for_slave_io_error.inc [errno=1236]
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
include/stop_slave_sql.inc
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB

View file

@ -5,6 +5,7 @@ CREATE TABLE t1(c1 INT);
FLUSH LOGS;
call mtr.add_suppression('Got fatal error 1236 from master when reading data from binary log: .*could not find next log');
include/wait_for_slave_io_error.inc [errno=1236]
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'could not find next log; the last event was read from 'master-bin.000002' at XXX, the last byte read was read from 'master-bin.000002' at XXX.''
CREATE TABLE t2(c1 INT);
FLUSH LOGS;
CREATE TABLE t3(c1 INT);

View file

@ -37,6 +37,7 @@ DROP TABLE t1;
CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM;
INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet));
include/wait_for_slave_io_error.inc [errno=1236]
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
STOP SLAVE;
RESET SLAVE;
RESET MASTER;

View file

@ -6,6 +6,8 @@
source include/have_debug.inc;
source include/master-slave.inc;
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
# Currently only statement-based-specific bugs are here
-- source include/have_binlog_format_statement.inc

View file

@ -22,12 +22,9 @@ let $status_items= Read_Master_Log_Pos;
source include/show_slave_status.inc;
start slave;
let $slave_io_errno= 1236;
#
# Win and Unix path is printed differently: BUG#13055685. So
# show_slave_io_error is made 0 until the bug fixes provide necessary
# facilities
#
let $show_slave_io_error= 0;
--let $show_slave_io_error= 1
# Mask line numbers, and whether master-bin is preceded by "./" or "."
--let $slave_io_error_replace= / at [0-9]*/ at XXX/ /\.\/*master-bin/master-bin/
source include/wait_for_slave_io_error.inc;
source include/stop_slave_sql.inc;

View file

@ -60,12 +60,9 @@ call mtr.add_suppression('Got fatal error 1236 from master when reading data fro
connection slave;
# 1236 = ER_MASTER_FATAL_ERROR_READING_BINLOG
--let $slave_io_errno= 1236
#
# Win and Unix path is printed differently: BUG#13055685. So
# show_slave_io_error is made 0 until the bug fixes provide necessary
# facilities
#
--let $show_slave_io_error= 0
--let $show_slave_io_error= 1
# Mask line numbers, and whether master-bin is preceded by "./" or "."
--let $slave_io_error_replace= / at [0-9]*/ at XXX/ /\.\/*master-bin/master-bin/
--source include/wait_for_slave_io_error.inc
connection master;

View file

@ -125,12 +125,9 @@ connection slave;
# The slave I/O thread must stop after receiving
# 1236=ER_MASTER_FATAL_ERROR_READING_BINLOG error message from master.
--let $slave_io_errno= 1236
#
# Win and Unix path is printed differently: BUG#13055685. So
# show_slave_io_error is made 0 until the bug fixes provide necessary
# facilities
#
--let $show_slave_io_error= 0
# Mask line numbers, and whether master-bin is preceded by "./" or "."
--let $slave_io_error_replace= / at [0-9]*/ at XXX/ /\.\/*master-bin/master-bin/
--source include/wait_for_slave_io_error.inc
# Remove the bad binlog and clear error status on slave.

View file

@ -4,6 +4,7 @@ load data infile "MYSQLTEST_VARDIR/tmp/sys_vars.all_vars.txt" into table t1;
insert into t2 select variable_name from information_schema.global_variables;
insert into t2 select variable_name from information_schema.session_variables;
delete from t2 where variable_name='innodb_change_buffering_debug';
delete from t2 where variable_name='innodb_trx_rseg_n_slots_debug';
update t2 set variable_name= replace(variable_name, "PERFORMANCE_SCHEMA_", "PFS_");
select variable_name as `There should be *no* long test name listed below:` from t2
where length(variable_name) > 50;

View file

@ -49,6 +49,7 @@ insert into t2 select variable_name from information_schema.session_variables;
# This is only present in debug builds.
delete from t2 where variable_name='innodb_change_buffering_debug';
delete from t2 where variable_name='innodb_trx_rseg_n_slots_debug';
# Performance schema variables are too long for files named
# 'mysql-test/suite/sys_vars/t/' ...

View file

@ -11,5 +11,7 @@
##############################################################################
transaction_prealloc_size_basic_32 : Bug#11748572
transaction_prealloc_size_basic_64 : Bug#11748572
query_cache_size_basic_32 : Bug#13535584
query_cache_size_basic_64 : Bug#11748572
#thread_cache_size_func : Bug#11750172: 2008-11-07 joro main.thread_cache_size_func fails in pushbuild when run with pool of threads

View file

@ -940,6 +940,21 @@ SELECT MONTHNAME(0), MONTHNAME(0) IS NULL, MONTHNAME(0) + 1;
--error ER_WRONG_VALUE_FOR_VAR
SET storage_engine=NULL;
--echo #
--echo # BUG#13354387 - CRASH IN IN MY_DECIMAL::OPERATOR FOR VIEW AND FUNCTION UNIX_TIMESTAMP
--echo # Part1 (5.5)
SET time_zone='+03:00';
CREATE TABLE t1 (a DATETIME NOT NULL);
INSERT INTO t1 VALUES ('2009-09-20 07:32:39.06');
INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00');
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT CAST(UNIX_TIMESTAMP(a) AS DECIMAL(25,3)) AS c1 FROM v1 ORDER BY 1;
DROP VIEW v1;
DROP TABLE t1;
SET time_zone=DEFAULT;
--echo #
--echo # Bug #59686 crash in String::copy() with time data type
--echo #

View file

@ -36,6 +36,14 @@ connection con0;
set GLOBAL init_connect="adsfsdfsdfs";
connect (con5,localhost,user_1,,);
connection con5;
# BUG#11755281/47032: ERROR 2006 / ERROR 2013 INSTEAD OF PROPER ERROR MESSAGE
# We now throw a proper error message here:
--replace_regex /connection .* to/connection to/
--error ER_NEW_ABORTING_CONNECTION
select @a;
# We got disconnected after receiving the above error message; any further
# requests should fail with a notice that no one's listening to us.
# --error CR_SERVER_GONE_ERROR,CR_SERVER_LOST
--error 2013,2006
select @a;
connection con0;

View file

@ -2201,6 +2201,118 @@ DROP DATABASE `test-database`;
# Switching back to test database.
USE test;
--echo #
--echo # BUG#11760384 : 52792: mysqldump in XML mode does not dump routines.
--echo #
CREATE DATABASE BUG52792;
USE BUG52792;
CREATE TABLE t1 (c1 INT, c2 VARCHAR(20));
CREATE TABLE t2 (c1 INT);
INSERT INTO t1 VALUES (1, 'aaa'), (2, 'bbb'), (3, 'ccc');
INSERT INTO t2 VALUES (1),(2),(3);
--echo # Stored Procedures.
DELIMITER //;
CREATE PROCEDURE simpleproc1 (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t1;
END//
DELIMITER ;//
DELIMITER //;
CREATE PROCEDURE simpleproc2 (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t2;
END//
DELIMITER ;//
--echo # Events.
CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792;
CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792;
--echo # Functions.
CREATE FUNCTION `hello1` (s CHAR(20))
RETURNS CHAR(50) DETERMINISTIC
RETURN CONCAT('Hello, ' ,s ,'!');
CREATE FUNCTION `hello2` (s CHAR(20))
RETURNS CHAR(50) DETERMINISTIC
RETURN CONCAT(']]>, ' , s ,'!');
--echo # Triggers.
DELIMITER |;
CREATE TRIGGER trig1 BEFORE INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1);
END;
|
DELIMITER ;|
DELIMITER |;
CREATE TRIGGER trig2 AFTER INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1, ']]>');
INSERT INTO t2 VALUES(2, '<![CDATA]]>');
INSERT INTO t2 VALUES(3, '<![CDATA[');
INSERT INTO t2 VALUES(4, '< > & \ " _');
END;
|
DELIMITER ;|
--echo # Views
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE VIEW v2 AS SELECT * FROM t2;
--echo
--echo # Dumping BUG52792 database in xml format.
--echo
--echo # Running 'replace_regex on timestamp'
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/
--exec $MYSQL_DUMP --user=root --compact -R -E --triggers -X BUG52792
--echo
--echo # Dumping BUG52792 database in xml format with comments.
--echo
--echo # Running 'replace_regex on timestamp'
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/
--exec $MYSQL_DUMP --comments --user=root -R -E --triggers -X BUG52792
--echo
--echo # Test to check 'Insufficient privileges' error.
--echo
GRANT ALL PRIVILEGES ON BUG52792.* TO user1;
connect (conn_1, localhost, user1, , BUG52792, $MASTER_MYPORT, $MASTER_MYSOCK);
connection conn_1;
--echo # Running 'replace_regex on timestamp'
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/
--error 2
--exec $MYSQL_DUMP --user=user1 -R -E --triggers -X BUG52792
connection default;
disconnect conn_1;
DROP USER user1;
DROP DATABASE BUG52792;
--echo # UTF-8
CREATE DATABASE BUG52792;
USE BUG52792;
SET NAMES utf8;
CREATE FUNCTION `straße` ( c1 CHAR(20))
RETURNS CHAR(50) DETERMINISTIC
RETURN CONCAT(']]>, ', s, '!');
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 -R -X BUG52792
DROP DATABASE BUG52792;
USE test;
--echo #
--echo # End of 5.1 tests
--echo #
@ -2215,5 +2327,43 @@ CREATE TABLE t1 (a INT);
--exec $MYSQL_DUMP --compatible=no_t,no_f --skip-comments test
DROP TABLE t1;
--echo #
--echo # Bug#12809202 61854: MYSQLDUMP --SINGLE-TRANSACTION --FLUSH-LOG BREAKS
--echo # CONSISTENCY
--echo #
--disable_warnings
DROP DATABASE IF EXISTS b12809202_db;
--enable_warnings
CREATE DATABASE b12809202_db;
CREATE TABLE b12809202_db.t1 (c1 INT);
CREATE TABLE b12809202_db.t2 (c1 INT);
INSERT INTO b12809202_db.t1 VALUES (1), (2), (3);
INSERT INTO b12809202_db.t2 VALUES (1), (2), (3);
--echo # Starting mysqldump with --single-transaction & --flush-log options..
--echo # Note : In the following dump the transaction
--echo # should start only after the logs are
--echo # flushed, as 'flush logs' causes implicit
--echo # commit starting 5.5.
--echo
--echo #### Dump starts here ####
--replace_regex /-- Server version.*// /-- MySQL dump .*// /-- Dump completed on .*/-- Dump completed/
--exec $MYSQL_DUMP --verbose --single-transaction --flush-log b12809202_db 2>&1
--echo
--echo #### Dump ends here ####
# Cleanup
DROP TABLE b12809202_db.t1;
DROP TABLE b12809202_db.t2;
DROP DATABASE b12809202_db;
--echo #
--echo # Delete all existing binary logs.
--echo #
RESET MASTER;
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc

View file

@ -3336,28 +3336,20 @@ drop table t3|
--disable_warnings
drop procedure if exists bug6857|
--enable_warnings
create procedure bug6857(counter int)
create procedure bug6857()
begin
declare t0, t1 int;
declare plus bool default 0;
set t0 = current_time();
while counter > 0 do
set counter = counter - 1;
end while;
set t1 = current_time();
set t0 = unix_timestamp();
select sleep(1.1);
set t1 = unix_timestamp();
if t1 > t0 then
set plus = 1;
end if;
select plus;
end|
# QQ: This is currently disabled. Not only does it slow down a normal test
# run, it makes running with valgrind (or similar tools) extremely
# painful.
# Make sure this takes at least one second on all machines in all builds.
# 30000 makes it about 3 seconds on an old 1.1GHz linux.
#call bug6857(300000)|
call bug6857()|
drop procedure bug6857|

View file

@ -6812,7 +6812,9 @@ bool Item_direct_ref::is_null()
bool Item_direct_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
return (null_value=(*ref)->get_date(ltime,fuzzydate));
bool tmp= (*ref)->get_date(ltime, fuzzydate);
null_value= (*ref)->null_value;
return tmp;
}

View file

@ -668,13 +668,38 @@ void prepare_new_connection_state(THD* thd)
execute_init_command(thd, &opt_init_connect, &LOCK_sys_init_connect);
if (thd->is_error())
{
thd->killed= THD::KILL_CONNECTION;
ulong packet_length;
NET *net= &thd->net;
sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION),
thd->thread_id,(thd->db ? thd->db : "unconnected"),
thd->thread_id,
thd->db ? thd->db : "unconnected",
sctx->user ? sctx->user : "unauthenticated",
sctx->host_or_ip, "init_connect command failed");
sql_print_warning("%s", thd->stmt_da->message());
thd->lex->current_select= 0;
my_net_set_read_timeout(net, thd->variables.net_wait_timeout);
thd->clear_error();
net_new_transaction(net);
packet_length= my_net_read(net);
/*
If my_net_read() failed, my_error() has been already called,
and the main Diagnostics Area contains an error condition.
*/
if (packet_length != packet_error)
my_error(ER_NEW_ABORTING_CONNECTION, MYF(0),
thd->thread_id,
thd->db ? thd->db : "unconnected",
sctx->user ? sctx->user : "unauthenticated",
sctx->host_or_ip, "init_connect command failed");
thd->server_status&= ~SERVER_STATUS_CLEAR_SET;
thd->protocol->end_statement();
thd->killed = THD::KILL_CONNECTION;
return;
}
thd->proc_info=0;
thd->set_time();
thd->init_for_queries();

View file

@ -1685,6 +1685,16 @@ int ha_federated::close(void)
mysql_close(mysql);
mysql= NULL;
/*
mysql_close() might return an error if a remote server's gone
for some reason. If that happens while removing a table from
the table cache, the error will be propagated to a client even
if the original query was not issued against the FEDERATED table.
So, don't propagate errors from mysql_close().
*/
if (table->in_use)
table->in_use->clear_error();
DBUG_RETURN(free_share(share));
}

View file

@ -52,12 +52,13 @@ btr_pcur_create_for_mysql(void)
}
/**************************************************************//**
Frees the memory for a persistent cursor object. */
Resets a persistent cursor object, freeing ::old_rec_buf if it is
allocated and resetting the other members to their initial values. */
UNIV_INTERN
void
btr_pcur_free_for_mysql(
/*====================*/
btr_pcur_t* cursor) /*!< in, own: persistent cursor */
btr_pcur_reset(
/*===========*/
btr_pcur_t* cursor) /*!< in, out: persistent cursor */
{
if (cursor->old_rec_buf != NULL) {
@ -66,6 +67,7 @@ btr_pcur_free_for_mysql(
cursor->old_rec_buf = NULL;
}
cursor->btr_cur.index = NULL;
cursor->btr_cur.page_cur.rec = NULL;
cursor->old_rec = NULL;
cursor->old_n_fields = 0;
@ -73,7 +75,17 @@ btr_pcur_free_for_mysql(
cursor->latch_mode = BTR_NO_LATCHES;
cursor->pos_state = BTR_PCUR_NOT_POSITIONED;
}
/**************************************************************//**
Frees the memory for a persistent cursor object. */
UNIV_INTERN
void
btr_pcur_free_for_mysql(
/*====================*/
btr_pcur_t* cursor) /*!< in, own: persistent cursor */
{
btr_pcur_reset(cursor);
mem_free(cursor);
}

View file

@ -989,11 +989,8 @@ buf_chunk_init(
for (i = chunk->size; i--; ) {
buf_block_init(buf_pool, block, frame);
UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
#ifdef HAVE_purify
/* Wipe contents of frame to eliminate a Purify warning */
memset(block->frame, '\0', UNIV_PAGE_SIZE);
#endif
/* Add the block to the free list */
UT_LIST_ADD_LAST(list, buf_pool->free, (&block->page));

View file

@ -2066,8 +2066,9 @@ static
void
dict_load_foreign_cols(
/*===================*/
const char* id, /*!< in: foreign constraint id as a
null-terminated string */
const char* id, /*!< in: foreign constraint id, not
necessary '\0'-terminated */
ulint id_len, /*!< in: id length */
dict_foreign_t* foreign)/*!< in: foreign constraint object */
{
dict_table_t* sys_foreign_cols;
@ -2097,7 +2098,7 @@ dict_load_foreign_cols(
tuple = dtuple_create(foreign->heap, 1);
dfield = dtuple_get_nth_field(tuple, 0);
dfield_set_data(dfield, id, ut_strlen(id));
dfield_set_data(dfield, id, id_len);
dict_index_copy_types(tuple, sys_index, 1);
btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
@ -2110,7 +2111,7 @@ dict_load_foreign_cols(
ut_a(!rec_get_deleted_flag(rec, 0));
field = rec_get_nth_field_old(rec, 0, &len);
ut_a(len == ut_strlen(id));
ut_a(len == id_len);
ut_a(ut_memcmp(id, field, len) == 0);
field = rec_get_nth_field_old(rec, 1, &len);
@ -2139,8 +2140,9 @@ static
ulint
dict_load_foreign(
/*==============*/
const char* id, /*!< in: foreign constraint id as a
null-terminated string */
const char* id, /*!< in: foreign constraint id, not
necessary '\0'-terminated */
ulint id_len, /*!< in: id length */
ibool check_charsets,
/*!< in: TRUE=check charset compatibility */
ibool check_recursive)
@ -2176,7 +2178,7 @@ dict_load_foreign(
tuple = dtuple_create(heap2, 1);
dfield = dtuple_get_nth_field(tuple, 0);
dfield_set_data(dfield, id, ut_strlen(id));
dfield_set_data(dfield, id, id_len);
dict_index_copy_types(tuple, sys_index, 1);
btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
@ -2188,8 +2190,8 @@ dict_load_foreign(
/* Not found */
fprintf(stderr,
"InnoDB: Error A: cannot load foreign constraint %s\n",
id);
"InnoDB: Error A: cannot load foreign constraint "
"%.*s\n", (int) id_len, id);
btr_pcur_close(&pcur);
mtr_commit(&mtr);
@ -2201,11 +2203,11 @@ dict_load_foreign(
field = rec_get_nth_field_old(rec, 0, &len);
/* Check if the id in record is the searched one */
if (len != ut_strlen(id) || ut_memcmp(id, field, len) != 0) {
if (len != id_len || ut_memcmp(id, field, len) != 0) {
fprintf(stderr,
"InnoDB: Error B: cannot load foreign constraint %s\n",
id);
"InnoDB: Error B: cannot load foreign constraint "
"%.*s\n", (int) id_len, id);
btr_pcur_close(&pcur);
mtr_commit(&mtr);
@ -2231,7 +2233,7 @@ dict_load_foreign(
foreign->type = (unsigned int) (n_fields_and_type >> 24);
foreign->n_fields = (unsigned int) (n_fields_and_type & 0x3FFUL);
foreign->id = mem_heap_strdup(foreign->heap, id);
foreign->id = mem_heap_strdupl(foreign->heap, id, id_len);
field = rec_get_nth_field_old(rec, 3, &len);
@ -2247,7 +2249,7 @@ dict_load_foreign(
btr_pcur_close(&pcur);
mtr_commit(&mtr);
dict_load_foreign_cols(id, foreign);
dict_load_foreign_cols(id, id_len, foreign);
ref_table = dict_table_check_if_in_cache_low(
foreign->referenced_table_name_lookup);
@ -2326,8 +2328,8 @@ dict_load_foreigns(
ibool check_charsets) /*!< in: TRUE=check charset
compatibility */
{
char tuple_buf[DTUPLE_EST_ALLOC(1)];
btr_pcur_t pcur;
mem_heap_t* heap;
dtuple_t* tuple;
dfield_t* dfield;
dict_index_t* sec_index;
@ -2335,7 +2337,6 @@ dict_load_foreigns(
const rec_t* rec;
const byte* field;
ulint len;
char* id ;
ulint err;
mtr_t mtr;
@ -2362,9 +2363,8 @@ dict_load_foreigns(
sec_index = dict_table_get_next_index(
dict_table_get_first_index(sys_foreign));
start_load:
heap = mem_heap_create(256);
tuple = dtuple_create(heap, 1);
tuple = dtuple_create_from_mem(tuple_buf, sizeof(tuple_buf), 1);
dfield = dtuple_get_nth_field(tuple, 0);
dfield_set_data(dfield, table_name, ut_strlen(table_name));
@ -2418,7 +2418,6 @@ loop:
/* Now we get a foreign key constraint id */
field = rec_get_nth_field_old(rec, 1, &len);
id = mem_heap_strdupl(heap, (char*) field, len);
btr_pcur_store_position(&pcur, &mtr);
@ -2426,11 +2425,11 @@ loop:
/* Load the foreign constraint definition to the dictionary cache */
err = dict_load_foreign(id, check_charsets, check_recursive);
err = dict_load_foreign((char*) field, len, check_charsets,
check_recursive);
if (err != DB_SUCCESS) {
btr_pcur_close(&pcur);
mem_heap_free(heap);
return(err);
}
@ -2446,7 +2445,6 @@ next_rec:
load_next_index:
btr_pcur_close(&pcur);
mtr_commit(&mtr);
mem_heap_free(heap);
sec_index = dict_table_get_next_index(sec_index);

View file

@ -3737,22 +3737,9 @@ ha_innobase::open(
DBUG_RETURN(1);
}
/* Create buffers for packing the fields of a record. Why
table->reclength did not work here? Obviously, because char
fields when packed actually became 1 byte longer, when we also
stored the string length as the first byte. */
upd_and_key_val_buff_len =
table->s->reclength + table->s->max_key_length
+ MAX_REF_PARTS * 3;
if (!(uchar*) my_multi_malloc(MYF(MY_WME),
&upd_buff, upd_and_key_val_buff_len,
&key_val_buff, upd_and_key_val_buff_len,
NullS)) {
free_share(share);
DBUG_RETURN(1);
}
/* Will be allocated if it is needed in ::update_row() */
upd_buf = NULL;
upd_buf_size = 0;
/* We look for pattern #P# to see if the table is partitioned
MySQL table. The retry logic for partitioned tables is a
@ -3793,7 +3780,6 @@ retry:
"how you can resolve the problem.\n",
norm_name);
free_share(share);
my_free(upd_buff);
my_errno = ENOENT;
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
@ -3809,16 +3795,14 @@ retry:
"how you can resolve the problem.\n",
norm_name);
free_share(share);
my_free(upd_buff);
my_errno = ENOENT;
dict_table_decrement_handle_count(ib_table, FALSE);
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
}
prebuilt = row_create_prebuilt(ib_table);
prebuilt = row_create_prebuilt(ib_table, table->s->reclength);
prebuilt->mysql_row_len = table->s->reclength;
prebuilt->default_rec = table->s->default_values;
ut_ad(prebuilt->default_rec);
@ -4007,7 +3991,13 @@ ha_innobase::close(void)
row_prebuilt_free(prebuilt, FALSE);
my_free(upd_buff);
if (upd_buf != NULL) {
ut_ad(upd_buf_size != 0);
my_free(upd_buf);
upd_buf = NULL;
upd_buf_size = 0;
}
free_share(share);
/* Tell InnoDB server that there might be work for
@ -5300,6 +5290,23 @@ ha_innobase::update_row(
ut_a(prebuilt->trx == trx);
if (upd_buf == NULL) {
ut_ad(upd_buf_size == 0);
/* Create a buffer for packing the fields of a record. Why
table->reclength did not work here? Obviously, because char
fields when packed actually became 1 byte longer, when we also
stored the string length as the first byte. */
upd_buf_size = table->s->reclength + table->s->max_key_length
+ MAX_REF_PARTS * 3;
upd_buf = (uchar*) my_malloc(upd_buf_size, MYF(MY_WME));
if (upd_buf == NULL) {
upd_buf_size = 0;
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
}
ha_statistic_increment(&SSV::ha_update_count);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
@ -5312,11 +5319,10 @@ ha_innobase::update_row(
}
/* Build an update vector from the modified fields in the rows
(uses upd_buff of the handle) */
(uses upd_buf of the handle) */
calc_row_difference(uvect, (uchar*) old_row, new_row, table,
upd_buff, (ulint)upd_and_key_val_buff_len,
prebuilt, user_thd);
upd_buf, upd_buf_size, prebuilt, user_thd);
/* This is not a delete */
prebuilt->upd_node->is_delete = FALSE;
@ -5693,8 +5699,7 @@ ha_innobase::index_read(
row_sel_convert_mysql_key_to_innobase(
prebuilt->search_tuple,
(byte*) key_val_buff,
(ulint)upd_and_key_val_buff_len,
srch_key_val1, sizeof(srch_key_val1),
index,
(byte*) key_ptr,
(ulint) key_len,
@ -7512,12 +7517,6 @@ ha_innobase::records_in_range(
{
KEY* key;
dict_index_t* index;
uchar* key_val_buff2 = (uchar*) my_malloc(
table->s->reclength
+ table->s->max_key_length + 100,
MYF(MY_FAE));
ulint buff2_len = table->s->reclength
+ table->s->max_key_length + 100;
dtuple_t* range_start;
dtuple_t* range_end;
ib_int64_t n_rows;
@ -7569,8 +7568,8 @@ ha_innobase::records_in_range(
dict_index_copy_types(range_end, index, key->key_parts);
row_sel_convert_mysql_key_to_innobase(
range_start, (byte*) key_val_buff,
(ulint)upd_and_key_val_buff_len,
range_start,
srch_key_val1, sizeof(srch_key_val1),
index,
(byte*) (min_key ? min_key->key :
(const uchar*) 0),
@ -7581,8 +7580,9 @@ ha_innobase::records_in_range(
: range_start->n_fields == 0);
row_sel_convert_mysql_key_to_innobase(
range_end, (byte*) key_val_buff2,
buff2_len, index,
range_end,
srch_key_val2, sizeof(srch_key_val2),
index,
(byte*) (max_key ? max_key->key :
(const uchar*) 0),
(ulint) (max_key ? max_key->length : 0),
@ -7609,7 +7609,6 @@ ha_innobase::records_in_range(
mem_heap_free(heap);
func_exit:
my_free(key_val_buff2);
prebuilt->trx->op_info = (char*)"";
@ -11438,6 +11437,13 @@ static MYSQL_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
"trigger a readahead.",
NULL, NULL, 56, 0, 64, 0);
#ifdef UNIV_DEBUG
static MYSQL_SYSVAR_UINT(trx_rseg_n_slots_debug, trx_rseg_n_slots_debug,
PLUGIN_VAR_RQCMDARG,
"Debug flags for InnoDB to limit TRX_RSEG_N_SLOTS for trx_rsegf_undo_find_free()",
NULL, NULL, 0, 0, 1024, 0);
#endif /* UNIV_DEBUG */
static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(additional_mem_pool_size),
MYSQL_SYSVAR(autoextend_increment),
@ -11507,6 +11513,9 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(purge_threads),
MYSQL_SYSVAR(purge_batch_size),
MYSQL_SYSVAR(rollback_segments),
#ifdef UNIV_DEBUG
MYSQL_SYSVAR(trx_rseg_n_slots_debug),
#endif /* UNIV_DEBUG */
NULL
};

View file

@ -78,13 +78,14 @@ class ha_innobase: public handler
INNOBASE_SHARE* share; /*!< information for MySQL
table locking */
uchar* upd_buff; /*!< buffer used in updates */
uchar* key_val_buff; /*!< buffer used in converting
uchar* upd_buf; /*!< buffer used in updates */
ulint upd_buf_size; /*!< the size of upd_buf in bytes */
uchar srch_key_val1[REC_VERSION_56_MAX_INDEX_COL_LEN + 2];
uchar srch_key_val2[REC_VERSION_56_MAX_INDEX_COL_LEN + 2];
/*!< buffers used in converting
search key values from MySQL format
to Innodb format */
ulong upd_and_key_val_buff_len;
/* the length of each of the previous
two buffers */
to InnoDB format. "+ 2" for the two
bytes where the length is stored */
Table_flags int_table_flags;
uint primary_key;
ulong start_of_scan; /*!< this is set to 1 when we are

View file

@ -1008,7 +1008,12 @@ ha_innobase::final_add_index(
row_prebuilt_free(prebuilt, TRUE);
error = row_merge_drop_table(trx, old_table);
add->indexed_table->n_mysql_handles_opened++;
prebuilt = row_create_prebuilt(add->indexed_table);
prebuilt = row_create_prebuilt(add->indexed_table,
0 /* XXX Do we know the mysql_row_len here?
Before the addition of this parameter to
row_create_prebuilt() the mysql_row_len
member was left 0 (from zalloc) in the
prebuilt object. */);
}
err = convert_error_code_to_mysql(

View file

@ -53,6 +53,16 @@ UNIV_INTERN
btr_pcur_t*
btr_pcur_create_for_mysql(void);
/*============================*/
/**************************************************************//**
Resets a persistent cursor object, freeing ::old_rec_buf if it is
allocated and resetting the other members to their initial values. */
UNIV_INTERN
void
btr_pcur_reset(
/*===========*/
btr_pcur_t* cursor);/*!< in, out: persistent cursor */
/**************************************************************//**
Frees the memory for a persistent cursor object. */
UNIV_INTERN

View file

@ -231,6 +231,26 @@ dtuple_set_n_fields_cmp(
dtuple_t* tuple, /*!< in: tuple */
ulint n_fields_cmp); /*!< in: number of fields used in
comparisons in rem0cmp.* */
/* Estimate the number of bytes that are going to be allocated when
creating a new dtuple_t object */
#define DTUPLE_EST_ALLOC(n_fields) \
(sizeof(dtuple_t) + (n_fields) * sizeof(dfield_t))
/**********************************************************//**
Creates a data tuple from an already allocated chunk of memory.
The size of the chunk must be at least DTUPLE_EST_ALLOC(n_fields).
The default value for number of fields used in record comparisons
for this tuple is n_fields.
@return created tuple (inside buf) */
UNIV_INLINE
dtuple_t*
dtuple_create_from_mem(
/*===================*/
void* buf, /*!< in, out: buffer to use */
ulint buf_size, /*!< in: buffer size */
ulint n_fields); /*!< in: number of fields */
/**********************************************************//**
Creates a data tuple to a memory heap. The default value for number
of fields used in record comparisons for this tuple is n_fields.
@ -240,7 +260,8 @@ dtuple_t*
dtuple_create(
/*==========*/
mem_heap_t* heap, /*!< in: memory heap where the tuple
is created */
is created, DTUPLE_EST_ALLOC(n_fields)
bytes will be allocated from this heap */
ulint n_fields); /*!< in: number of fields */
/**********************************************************//**

View file

@ -348,23 +348,25 @@ dtuple_get_nth_field(
#endif /* UNIV_DEBUG */
/**********************************************************//**
Creates a data tuple to a memory heap. The default value for number
of fields used in record comparisons for this tuple is n_fields.
@return own: created tuple */
Creates a data tuple from an already allocated chunk of memory.
The size of the chunk must be at least DTUPLE_EST_ALLOC(n_fields).
The default value for number of fields used in record comparisons
for this tuple is n_fields.
@return created tuple (inside buf) */
UNIV_INLINE
dtuple_t*
dtuple_create(
/*==========*/
mem_heap_t* heap, /*!< in: memory heap where the tuple
is created */
ulint n_fields) /*!< in: number of fields */
dtuple_create_from_mem(
/*===================*/
void* buf, /*!< in, out: buffer to use */
ulint buf_size, /*!< in: buffer size */
ulint n_fields) /*!< in: number of fields */
{
dtuple_t* tuple;
ut_ad(heap);
ut_ad(buf != NULL);
ut_a(buf_size >= DTUPLE_EST_ALLOC(n_fields));
tuple = (dtuple_t*) mem_heap_alloc(heap, sizeof(dtuple_t)
+ n_fields * sizeof(dfield_t));
tuple = (dtuple_t*) buf;
tuple->info_bits = 0;
tuple->n_fields = n_fields;
tuple->n_fields_cmp = n_fields;
@ -386,9 +388,38 @@ dtuple_create(
dfield_get_type(field)->mtype = DATA_ERROR;
}
}
#endif
return(tuple);
}
/**********************************************************//**
Creates a data tuple to a memory heap. The default value for number
of fields used in record comparisons for this tuple is n_fields.
@return own: created tuple */
UNIV_INLINE
dtuple_t*
dtuple_create(
/*==========*/
mem_heap_t* heap, /*!< in: memory heap where the tuple
is created, DTUPLE_EST_ALLOC(n_fields)
bytes will be allocated from this heap */
ulint n_fields) /*!< in: number of fields */
{
void* buf;
ulint buf_size;
dtuple_t* tuple;
ut_ad(heap);
buf_size = DTUPLE_EST_ALLOC(n_fields);
buf = mem_heap_alloc(heap, buf_size);
tuple = dtuple_create_from_mem(buf, buf_size, n_fields);
#ifdef UNIV_DEBUG
UNIV_MEM_INVALID(tuple->fields, n_fields * sizeof *tuple->fields);
#endif
return(tuple);
}

View file

@ -208,10 +208,6 @@ mem_heap_alloc(
caller */
buf = (byte*)buf + MEM_FIELD_HEADER_SIZE;
#endif
#ifdef UNIV_SET_MEM_TO_ZERO
UNIV_MEM_ALLOC(buf, n);
memset(buf, '\0', n);
#endif
UNIV_MEM_ALLOC(buf, n);
return(buf);

View file

@ -168,7 +168,9 @@ UNIV_INTERN
row_prebuilt_t*
row_create_prebuilt(
/*================*/
dict_table_t* table); /*!< in: Innobase table handle */
dict_table_t* table, /*!< in: Innobase table handle */
ulint mysql_row_len); /*!< in: length in bytes of a row in
the MySQL format */
/********************************************************************//**
Free a prebuilt struct for a MySQL table handle. */
UNIV_INTERN
@ -672,9 +674,9 @@ struct row_prebuilt_struct {
in inserts */
que_fork_t* upd_graph; /*!< Innobase SQL query graph used
in updates or deletes */
btr_pcur_t* pcur; /*!< persistent cursor used in selects
btr_pcur_t pcur; /*!< persistent cursor used in selects
and updates */
btr_pcur_t* clust_pcur; /*!< persistent cursor used in
btr_pcur_t clust_pcur; /*!< persistent cursor used in
some selects and updates */
que_fork_t* sel_graph; /*!< dummy query graph used in
selects */

View file

@ -128,7 +128,12 @@ row_sel_convert_mysql_key_to_innobase(
in the tuple is already according
to index! */
byte* buf, /*!< in: buffer to use in field
conversions */
conversions; NOTE that dtuple->data
may end up pointing inside buf so
do not discard that buffer while
the tuple is being used. See
row_mysql_store_col_in_innobase_format()
in the case of DATA_INT */
ulint buf_len, /*!< in: buffer length */
dict_index_t* index, /*!< in: index of the key value */
const byte* key_ptr, /*!< in: MySQL key value */

View file

@ -25,6 +25,7 @@ Created 3/26/1996 Heikki Tuuri
#include "srv0srv.h"
#include "mtr0log.h"
#include "trx0sys.h"
/******************************************************************//**
Gets a rollback segment header.
@ -131,7 +132,13 @@ trx_rsegf_undo_find_free(
ulint i;
ulint page_no;
for (i = 0; i < TRX_RSEG_N_SLOTS; i++) {
for (i = 0;
#ifndef UNIV_DEBUG
i < TRX_RSEG_N_SLOTS;
#else
i < (trx_rseg_n_slots_debug ? trx_rseg_n_slots_debug : TRX_RSEG_N_SLOTS);
#endif
i++) {
page_no = trx_rsegf_get_nth_undo(rsegf, i, mtr);

View file

@ -223,6 +223,12 @@ trx_id_t
trx_sys_get_new_trx_id(void);
/*========================*/
#endif /* !UNIV_HOTBACKUP */
#ifdef UNIV_DEBUG
/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */
extern uint trx_rseg_n_slots_debug;
#endif
/*****************************************************************//**
Writes a trx id to an index page. In case that the id size changes in
some future version, this function should be used instead of

View file

@ -154,14 +154,6 @@ resolved */
/* DEBUG VERSION CONTROL
===================== */
/* The following flag will make InnoDB to initialize
all memory it allocates to zero. It hides Purify
warnings about reading unallocated memory unless
memory is read outside the allocated blocks. */
/*
#define UNIV_INIT_MEM_TO_ZERO
*/
/* When this macro is defined then additional test functions will be
compiled. These functions live at the end of each relevant source file
and have "test_" prefix. These functions are not called from anywhere in
@ -231,15 +223,6 @@ operations (very slow); also UNIV_DEBUG must be defined */
#define UNIV_BTR_DEBUG /* check B-tree links */
#define UNIV_LIGHT_MEM_DEBUG /* light memory debugging */
#ifdef HAVE_purify
/* The following sets all new allocated memory to zero before use:
this can be used to eliminate unnecessary Purify warnings, but note that
it also masks many bugs Purify could detect. For detailed Purify analysis it
is best to remove the define below and look through the warnings one
by one. */
#define UNIV_SET_MEM_TO_ZERO
#endif
/*
#define UNIV_SQL_DEBUG
#define UNIV_LOG_DEBUG

View file

@ -78,40 +78,19 @@ ut_mem_init(void);
/*=============*/
/**********************************************************************//**
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
defined and set_to_zero is TRUE.
Allocates memory.
@return own: allocated memory */
UNIV_INTERN
void*
ut_malloc_low(
/*==========*/
ulint n, /*!< in: number of bytes to allocate */
ibool set_to_zero, /*!< in: TRUE if allocated memory
should be set to zero if
UNIV_SET_MEM_TO_ZERO is defined */
ibool assert_on_error); /*!< in: if TRUE, we crash mysqld if
ibool assert_on_error) /*!< in: if TRUE, we crash mysqld if
the memory cannot be allocated */
__attribute__((malloc));
/**********************************************************************//**
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
defined.
@return own: allocated memory */
UNIV_INTERN
void*
ut_malloc(
/*======*/
ulint n); /*!< in: number of bytes to allocate */
#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs
out. It cannot be used if we want to return an error message. Prints to
stderr a message if fails.
@return TRUE if succeeded */
UNIV_INTERN
ibool
ut_test_malloc(
/*===========*/
ulint n); /*!< in: try to allocate this many bytes */
#endif /* !UNIV_HOTBACKUP */
Allocates memory. */
#define ut_malloc(n) ut_malloc_low(n, TRUE)
/**********************************************************************//**
Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is
a nop. */

View file

@ -114,7 +114,7 @@ ut_rnd_interval(
rnd = ut_rnd_gen_ulint();
return(low + (rnd % (high - low + 1)));
return(low + (rnd % (high - low)));
}
/*********************************************************//**

View file

@ -228,11 +228,7 @@ mem_pool_create(
pool = ut_malloc(sizeof(mem_pool_t));
/* We do not set the memory to zero (FALSE) in the pool,
but only when allocated at a higher level in mem0mem.c.
This is to avoid masking useful Purify warnings. */
pool->buf = ut_malloc_low(size, FALSE, TRUE);
pool->buf = ut_malloc_low(size, TRUE);
pool->size = size;
mutex_create(mem_pool_mutex_key, &pool->mutex, SYNC_MEM_POOL);

View file

@ -111,9 +111,6 @@ os_mem_alloc_large(
os_fast_mutex_lock(&ut_list_mutex);
ut_total_allocated_memory += size;
os_fast_mutex_unlock(&ut_list_mutex);
# ifdef UNIV_SET_MEM_TO_ZERO
memset(ptr, '\0', size);
# endif
UNIV_MEM_ALLOC(ptr, size);
return(ptr);
}

View file

@ -1857,7 +1857,7 @@ pars_sql(
ut_ad(str);
heap = mem_heap_create(256);
heap = mem_heap_create(16000);
/* Currently, the parser is not reentrant: */
ut_ad(mutex_own(&(dict_sys->mutex)));

View file

@ -667,17 +667,60 @@ UNIV_INTERN
row_prebuilt_t*
row_create_prebuilt(
/*================*/
dict_table_t* table) /*!< in: Innobase table handle */
dict_table_t* table, /*!< in: Innobase table handle */
ulint mysql_row_len) /*!< in: length in bytes of a row in
the MySQL format */
{
row_prebuilt_t* prebuilt;
mem_heap_t* heap;
dict_index_t* clust_index;
dtuple_t* ref;
ulint ref_len;
ulint search_tuple_n_fields;
heap = mem_heap_create(sizeof *prebuilt + 128);
search_tuple_n_fields = 2 * dict_table_get_n_cols(table);
prebuilt = mem_heap_zalloc(heap, sizeof *prebuilt);
clust_index = dict_table_get_first_index(table);
/* Make sure that search_tuple is long enough for clustered index */
ut_a(2 * dict_table_get_n_cols(table) >= clust_index->n_fields);
ref_len = dict_index_get_n_unique(clust_index);
#define PREBUILT_HEAP_INITIAL_SIZE \
( \
sizeof(*prebuilt) \
/* allocd in this function */ \
+ DTUPLE_EST_ALLOC(search_tuple_n_fields) \
+ DTUPLE_EST_ALLOC(ref_len) \
/* allocd in row_prebuild_sel_graph() */ \
+ sizeof(sel_node_t) \
+ sizeof(que_fork_t) \
+ sizeof(que_thr_t) \
/* allocd in row_get_prebuilt_update_vector() */ \
+ sizeof(upd_node_t) \
+ sizeof(upd_t) \
+ sizeof(upd_field_t) \
* dict_table_get_n_cols(table) \
+ sizeof(que_fork_t) \
+ sizeof(que_thr_t) \
/* allocd in row_get_prebuilt_insert_row() */ \
+ sizeof(ins_node_t) \
/* mysql_row_len could be huge and we are not \
sure if this prebuilt instance is going to be \
used in inserts */ \
+ (mysql_row_len < 256 ? mysql_row_len : 0) \
+ DTUPLE_EST_ALLOC(dict_table_get_n_cols(table)) \
+ sizeof(que_fork_t) \
+ sizeof(que_thr_t) \
)
/* We allocate enough space for the objects that are likely to
be created later in order to minimize the number of malloc()
calls */
heap = mem_heap_create(PREBUILT_HEAP_INITIAL_SIZE);
prebuilt = mem_heap_zalloc(heap, sizeof(*prebuilt));
prebuilt->magic_n = ROW_PREBUILT_ALLOCATED;
prebuilt->magic_n2 = ROW_PREBUILT_ALLOCATED;
@ -687,23 +730,15 @@ row_create_prebuilt(
prebuilt->sql_stat_start = TRUE;
prebuilt->heap = heap;
prebuilt->pcur = btr_pcur_create_for_mysql();
prebuilt->clust_pcur = btr_pcur_create_for_mysql();
btr_pcur_reset(&prebuilt->pcur);
btr_pcur_reset(&prebuilt->clust_pcur);
prebuilt->select_lock_type = LOCK_NONE;
prebuilt->stored_select_lock_type = 99999999;
UNIV_MEM_INVALID(&prebuilt->stored_select_lock_type,
sizeof prebuilt->stored_select_lock_type);
prebuilt->search_tuple = dtuple_create(
heap, 2 * dict_table_get_n_cols(table));
clust_index = dict_table_get_first_index(table);
/* Make sure that search_tuple is long enough for clustered index */
ut_a(2 * dict_table_get_n_cols(table) >= clust_index->n_fields);
ref_len = dict_index_get_n_unique(clust_index);
prebuilt->search_tuple = dtuple_create(heap, search_tuple_n_fields);
ref = dtuple_create(heap, ref_len);
@ -720,6 +755,8 @@ row_create_prebuilt(
prebuilt->autoinc_last_value = 0;
prebuilt->mysql_row_len = mysql_row_len;
return(prebuilt);
}
@ -755,8 +792,8 @@ row_prebuilt_free(
prebuilt->magic_n = ROW_PREBUILT_FREED;
prebuilt->magic_n2 = ROW_PREBUILT_FREED;
btr_pcur_free_for_mysql(prebuilt->pcur);
btr_pcur_free_for_mysql(prebuilt->clust_pcur);
btr_pcur_reset(&prebuilt->pcur);
btr_pcur_reset(&prebuilt->clust_pcur);
if (prebuilt->mysql_template) {
mem_free(prebuilt->mysql_template);
@ -1416,11 +1453,11 @@ row_update_for_mysql(
clust_index = dict_table_get_first_index(table);
if (prebuilt->pcur->btr_cur.index == clust_index) {
btr_pcur_copy_stored_position(node->pcur, prebuilt->pcur);
if (prebuilt->pcur.btr_cur.index == clust_index) {
btr_pcur_copy_stored_position(node->pcur, &prebuilt->pcur);
} else {
btr_pcur_copy_stored_position(node->pcur,
prebuilt->clust_pcur);
&prebuilt->clust_pcur);
}
ut_a(node->pcur->rel_pos == BTR_PCUR_ON);
@ -1524,8 +1561,8 @@ row_unlock_for_mysql(
clust_pcur, and we do not need
to reposition the cursors. */
{
btr_pcur_t* pcur = prebuilt->pcur;
btr_pcur_t* clust_pcur = prebuilt->clust_pcur;
btr_pcur_t* pcur = &prebuilt->pcur;
btr_pcur_t* clust_pcur = &prebuilt->clust_pcur;
trx_t* trx = prebuilt->trx;
ut_ad(prebuilt && trx);
@ -1954,6 +1991,20 @@ err_exit:
}
break;
case DB_TOO_MANY_CONCURRENT_TRXS:
/* We already have .ibd file here. it should be deleted. */
if (table->space && !fil_delete_tablespace(table->space)) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: not able to"
" delete tablespace %lu of table ",
(ulong) table->space);
ut_print_name(stderr, trx, TRUE, table->name);
fputs("!\n", stderr);
}
/* fall through */
case DB_DUPLICATE_KEY:
default:
/* We may also get err == DB_ERROR if the .ibd file for the

View file

@ -2301,7 +2301,12 @@ row_sel_convert_mysql_key_to_innobase(
in the tuple is already according
to index! */
byte* buf, /*!< in: buffer to use in field
conversions */
conversions; NOTE that dtuple->data
may end up pointing inside buf so
do not discard that buffer while
the tuple is being used. See
row_mysql_store_col_in_innobase_format()
in the case of DATA_INT */
ulint buf_len, /*!< in: buffer length */
dict_index_t* index, /*!< in: index of the key value */
const byte* key_ptr, /*!< in: MySQL key value */
@ -2433,6 +2438,7 @@ row_sel_convert_mysql_key_to_innobase(
/* Storing may use at most data_len bytes of buf */
if (UNIV_LIKELY(!is_null)) {
ut_a(buf + data_len <= original_buf + buf_len);
row_mysql_store_col_in_innobase_format(
dfield, buf,
FALSE, /* MySQL key value format col */
@ -2915,17 +2921,17 @@ row_sel_get_clust_rec_for_mysql(
btr_pcur_open_with_no_init(clust_index, prebuilt->clust_ref,
PAGE_CUR_LE, BTR_SEARCH_LEAF,
prebuilt->clust_pcur, 0, mtr);
&prebuilt->clust_pcur, 0, mtr);
clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur);
clust_rec = btr_pcur_get_rec(&prebuilt->clust_pcur);
prebuilt->clust_pcur->trx_if_known = trx;
prebuilt->clust_pcur.trx_if_known = trx;
/* Note: only if the search ends up on a non-infimum record is the
low_match value the real match to the search tuple */
if (!page_rec_is_user_rec(clust_rec)
|| btr_pcur_get_low_match(prebuilt->clust_pcur)
|| btr_pcur_get_low_match(&prebuilt->clust_pcur)
< dict_index_get_n_unique(clust_index)) {
/* In a rare case it is possible that no clust rec is found
@ -2974,7 +2980,7 @@ row_sel_get_clust_rec_for_mysql(
we set a LOCK_REC_NOT_GAP type lock */
err = lock_clust_rec_read_check_and_lock(
0, btr_pcur_get_block(prebuilt->clust_pcur),
0, btr_pcur_get_block(&prebuilt->clust_pcur),
clust_rec, clust_index, *offsets,
prebuilt->select_lock_type, LOCK_REC_NOT_GAP, thr);
switch (err) {
@ -3052,7 +3058,7 @@ func_exit:
/* We may use the cursor in update or in unlock_row():
store its position */
btr_pcur_store_position(prebuilt->clust_pcur, mtr);
btr_pcur_store_position(&prebuilt->clust_pcur, mtr);
}
err_exit:
@ -3300,7 +3306,7 @@ row_sel_try_search_shortcut_for_mysql(
{
dict_index_t* index = prebuilt->index;
const dtuple_t* search_tuple = prebuilt->search_tuple;
btr_pcur_t* pcur = prebuilt->pcur;
btr_pcur_t* pcur = &prebuilt->pcur;
trx_t* trx = prebuilt->trx;
const rec_t* rec;
@ -3389,7 +3395,7 @@ row_search_for_mysql(
dict_index_t* index = prebuilt->index;
ibool comp = dict_table_is_comp(index->table);
const dtuple_t* search_tuple = prebuilt->search_tuple;
btr_pcur_t* pcur = prebuilt->pcur;
btr_pcur_t* pcur = &prebuilt->pcur;
trx_t* trx = prebuilt->trx;
dict_index_t* clust_index;
que_thr_t* thr;

View file

@ -134,6 +134,11 @@ UNIV_INTERN mysql_pfs_key_t trx_doublewrite_mutex_key;
UNIV_INTERN mysql_pfs_key_t file_format_max_mutex_key;
#endif /* UNIV_PFS_MUTEX */
#ifdef UNIV_DEBUG
/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */
uint trx_rseg_n_slots_debug = 0;
#endif
#ifndef UNIV_HOTBACKUP
/** This is used to track the maximum file format id known to InnoDB. It's
updated via SET GLOBAL innodb_file_format_max = 'x' or when we open

View file

@ -84,17 +84,13 @@ ut_mem_init(void)
#endif /* !UNIV_HOTBACKUP */
/**********************************************************************//**
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
defined and set_to_zero is TRUE.
Allocates memory.
@return own: allocated memory */
UNIV_INTERN
void*
ut_malloc_low(
/*==========*/
ulint n, /*!< in: number of bytes to allocate */
ibool set_to_zero, /*!< in: TRUE if allocated memory should be
set to zero if UNIV_SET_MEM_TO_ZERO is
defined */
ibool assert_on_error)/*!< in: if TRUE, we crash mysqld if the
memory cannot be allocated */
{
@ -106,12 +102,6 @@ ut_malloc_low(
ret = malloc(n);
ut_a(ret || !assert_on_error);
#ifdef UNIV_SET_MEM_TO_ZERO
if (set_to_zero) {
memset(ret, '\0', n);
UNIV_MEM_ALLOC(ret, n);
}
#endif
return(ret);
}
@ -193,12 +183,6 @@ retry:
}
}
if (set_to_zero) {
#ifdef UNIV_SET_MEM_TO_ZERO
memset(ret, '\0', n + sizeof(ut_mem_block_t));
#endif
}
UNIV_MEM_ALLOC(ret, n + sizeof(ut_mem_block_t));
((ut_mem_block_t*)ret)->size = n + sizeof(ut_mem_block_t);
@ -215,74 +199,10 @@ retry:
void* ret = malloc(n);
ut_a(ret || !assert_on_error);
# ifdef UNIV_SET_MEM_TO_ZERO
if (set_to_zero) {
memset(ret, '\0', n);
}
# endif
return(ret);
#endif /* !UNIV_HOTBACKUP */
}
/**********************************************************************//**
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
defined.
@return own: allocated memory */
UNIV_INTERN
void*
ut_malloc(
/*======*/
ulint n) /*!< in: number of bytes to allocate */
{
#ifndef UNIV_HOTBACKUP
return(ut_malloc_low(n, TRUE, TRUE));
#else /* !UNIV_HOTBACKUP */
return(malloc(n));
#endif /* !UNIV_HOTBACKUP */
}
#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs
out. It cannot be used if we want to return an error message. Prints to
stderr a message if fails.
@return TRUE if succeeded */
UNIV_INTERN
ibool
ut_test_malloc(
/*===========*/
ulint n) /*!< in: try to allocate this many bytes */
{
void* ret;
ret = malloc(n);
if (ret == NULL) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: cannot allocate"
" %lu bytes of memory for\n"
"InnoDB: a BLOB with malloc! Total allocated memory\n"
"InnoDB: by InnoDB %lu bytes."
" Operating system errno: %d\n"
"InnoDB: Check if you should increase"
" the swap file or\n"
"InnoDB: ulimits of your operating system.\n"
"InnoDB: On FreeBSD check you have"
" compiled the OS with\n"
"InnoDB: a big enough maximum process size.\n",
(ulong) n,
(ulong) ut_total_allocated_memory,
(int) errno);
return(FALSE);
}
free(ret);
return(TRUE);
}
#endif /* !UNIV_HOTBACKUP */
/**********************************************************************//**
Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is
a nop. */