merge with 4.0.15

This commit is contained in:
monty@mashka.mysql.fi 2003-09-11 20:24:14 +03:00
commit 73f66f68fd
33 changed files with 646 additions and 361 deletions

View File

@ -22,6 +22,7 @@ carsten@tsort.bitbybit.dk
davida@isil.mysql.com davida@isil.mysql.com
dlenev@build.mysql.com dlenev@build.mysql.com
dlenev@mysql.com dlenev@mysql.com
gerberb@ou800.zenez.com
gluh@gluh.(none) gluh@gluh.(none)
gluh@gluh.mysql.r18.ru gluh@gluh.mysql.r18.ru
greg@gcw.ath.cx greg@gcw.ath.cx

View File

@ -297,7 +297,7 @@ static int dump_all_tables_in_db(char *db);
static int init_dumping(char *); static int init_dumping(char *);
static int dump_databases(char **); static int dump_databases(char **);
static int dump_all_databases(); static int dump_all_databases();
static char *quote_name(char *name, char *buff); static char *quote_name(const char *name, char *buff, my_bool force);
static void print_quoted_xml(FILE *output, char *fname, char *str, uint len); static void print_quoted_xml(FILE *output, char *fname, char *str, uint len);
static void print_version(void) static void print_version(void)
@ -347,7 +347,7 @@ static void write_header(FILE *sql_file, char *db_name)
fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION); fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
fprintf(sql_file, "-- Host: %s Database: %s\n", fprintf(sql_file, "-- Host: %s Database: %s\n",
current_host ? current_host : "localhost", db_name ? db_name : ""); current_host ? current_host : "localhost", db_name ? db_name : "");
fputs("---------------------------------------------------------\n", fputs("-- ------------------------------------------------------\n",
sql_file); sql_file);
fprintf(sql_file, "-- Server version\t%s\n", fprintf(sql_file, "-- Server version\t%s\n",
mysql_get_server_info(&mysql_connection)); mysql_get_server_info(&mysql_connection));
@ -631,33 +631,43 @@ static my_bool test_if_special_chars(const char *str)
return 0; return 0;
} /* test_if_special_chars */ } /* test_if_special_chars */
static char *quote_name(char *name, char *buff)
static char *quote_name(const char *name, char *buff, my_bool force)
{ {
char *end; char *to= buff;
if (!opt_quoted && !test_if_special_chars(name)) if (!force && !opt_quoted && !test_if_special_chars(name))
return name; return (char*) name;
buff[0]=QUOTE_CHAR; *to++= QUOTE_CHAR;
end=strmov(buff+1,name); while (*name)
end[0]=QUOTE_CHAR; {
end[1]=0; if (*name == QUOTE_CHAR)
*to= QUOTE_CHAR;
*to++= *name++;
}
to[0]=QUOTE_CHAR;
to[1]=0;
return buff; return buff;
} /* quote_name */ } /* quote_name */
/* /*
** getStructure -- retrievs database structure, prints out corresponding getStructure -- retrievs database structure, prints out corresponding
** CREATE statement and fills out insert_pat. CREATE statement and fills out insert_pat.
** Return values: number of fields in table, 0 if error
RETURN
number of fields in table, 0 if error
*/ */
static uint getTableStructure(char *table, char* db) static uint getTableStructure(char *table, char* db)
{ {
MYSQL_RES *tableRes; MYSQL_RES *tableRes;
MYSQL_ROW row; MYSQL_ROW row;
my_bool init=0; my_bool init=0;
uint numFields; uint numFields;
char *strpos, *table_name; char *strpos, *result_table, *opt_quoted_table;
const char *delayed; const char *delayed;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN+3]; char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3];
FILE *sql_file = md_result_file; FILE *sql_file = md_result_file;
DBUG_ENTER("getTableStructure"); DBUG_ENTER("getTableStructure");
@ -667,7 +677,8 @@ static uint getTableStructure(char *table, char* db)
fprintf(stderr, "-- Retrieving table structure for table %s...\n", table); fprintf(stderr, "-- Retrieving table structure for table %s...\n", table);
sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", (opt_quoted || opt_keywords)); sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", (opt_quoted || opt_keywords));
table_name=quote_name(table,table_buff); result_table= quote_name(table, table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
if (!mysql_query(sock,insert_pat)) if (!mysql_query(sock,insert_pat))
{ {
/* using SHOW CREATE statement */ /* using SHOW CREATE statement */
@ -691,7 +702,7 @@ static uint getTableStructure(char *table, char* db)
end= strmov(end, ","); end= strmov(end, ",");
} }
} }
end= strmov(--end, "\" */"); end= strmov(end-1, "\" */");
if (mysql_query(sock, buff)) if (mysql_query(sock, buff))
{ {
fprintf(stderr, "%s: Can't set the compatible mode '%s' (%s)\n", fprintf(stderr, "%s: Can't set the compatible mode '%s' (%s)\n",
@ -701,11 +712,11 @@ static uint getTableStructure(char *table, char* db)
} }
} }
sprintf(buff,"show create table `%s`",table); sprintf(buff,"show create table %s", result_table);
if (mysql_query(sock, buff)) if (mysql_query(sock, buff))
{ {
fprintf(stderr, "%s: Can't get CREATE TABLE for table '%s' (%s)\n", fprintf(stderr, "%s: Can't get CREATE TABLE for table %s (%s)\n",
my_progname, table, mysql_error(sock)); my_progname, result_table, mysql_error(sock));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -724,10 +735,10 @@ static uint getTableStructure(char *table, char* db)
write_header(sql_file, db); write_header(sql_file, db);
} }
if (!opt_xml) if (!opt_xml)
fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n", fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
table); result_table);
if (opt_drop) if (opt_drop)
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name); fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", opt_quoted_table);
tableRes=mysql_store_result(sock); tableRes=mysql_store_result(sock);
row=mysql_fetch_row(tableRes); row=mysql_fetch_row(tableRes);
@ -735,11 +746,11 @@ static uint getTableStructure(char *table, char* db)
fprintf(sql_file, "%s;\n", row[1]); fprintf(sql_file, "%s;\n", row[1]);
mysql_free_result(tableRes); mysql_free_result(tableRes);
} }
sprintf(insert_pat,"show fields from %s",table_name); sprintf(insert_pat,"show fields from %s", result_table);
if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock)))
{ {
fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", fprintf(stderr, "%s: Can't get info about table: %s\nerror: %s\n",
my_progname, table, mysql_error(sock)); my_progname, result_table, mysql_error(sock));
if (path) if (path)
my_fclose(sql_file, MYF(MY_WME)); my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
@ -747,10 +758,11 @@ static uint getTableStructure(char *table, char* db)
} }
if (cFlag) if (cFlag)
sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name); sprintf(insert_pat, "INSERT %sINTO %s (", delayed, opt_quoted_table);
else else
{ {
sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, table_name); sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed,
opt_quoted_table);
if (!extended_insert) if (!extended_insert)
strcat(insert_pat,"("); strcat(insert_pat,"(");
} }
@ -765,7 +777,7 @@ static uint getTableStructure(char *table, char* db)
} }
init=1; init=1;
if (cFlag) if (cFlag)
strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff)); strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME], name_buff, 0));
} }
numFields = (uint) mysql_num_rows(tableRes); numFields = (uint) mysql_num_rows(tableRes);
mysql_free_result(tableRes); mysql_free_result(tableRes);
@ -775,11 +787,11 @@ static uint getTableStructure(char *table, char* db)
/* fprintf(stderr, "%s: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n", /* fprintf(stderr, "%s: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
my_progname, mysql_error(sock)); */ my_progname, mysql_error(sock)); */
sprintf(insert_pat,"show fields from %s",table_name); sprintf(insert_pat,"show fields from %s", result_table);
if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock)))
{ {
fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", fprintf(stderr, "%s: Can't get info about table: %s\nerror: %s\n",
my_progname, table, mysql_error(sock)); my_progname, result_table, mysql_error(sock));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -801,17 +813,17 @@ static uint getTableStructure(char *table, char* db)
write_header(sql_file, db); write_header(sql_file, db);
} }
if (!opt_xml) if (!opt_xml)
fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n", fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
table); result_table);
if (opt_drop) if (opt_drop)
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name); fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",result_table);
fprintf(sql_file, "CREATE TABLE %s (\n", table_name); fprintf(sql_file, "CREATE TABLE %s (\n", result_table);
} }
if (cFlag) if (cFlag)
sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name); sprintf(insert_pat, "INSERT %sINTO %s (", delayed, result_table);
else else
{ {
sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, table_name); sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, result_table);
if (!extended_insert) if (!extended_insert)
strcat(insert_pat,"("); strcat(insert_pat,"(");
} }
@ -829,15 +841,17 @@ static uint getTableStructure(char *table, char* db)
} }
init=1; init=1;
if (cFlag) if (cFlag)
strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff)); strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME], name_buff, 0));
if (!tFlag) if (!tFlag)
{ {
if (opt_keywords) if (opt_keywords)
fprintf(sql_file, " %s.%s %s", table_name, fprintf(sql_file, " %s.%s %s", result_table,
quote_name(row[SHOW_FIELDNAME],name_buff), row[SHOW_TYPE]); quote_name(row[SHOW_FIELDNAME],name_buff, 0),
row[SHOW_TYPE]);
else else
fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME], fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME],
name_buff), row[SHOW_TYPE]); name_buff, 0),
row[SHOW_TYPE]);
if (row[SHOW_DEFAULT]) if (row[SHOW_DEFAULT])
{ {
fputs(" DEFAULT ", sql_file); fputs(" DEFAULT ", sql_file);
@ -856,11 +870,11 @@ static uint getTableStructure(char *table, char* db)
/* Make an sql-file, if path was given iow. option -T was given */ /* Make an sql-file, if path was given iow. option -T was given */
char buff[20+FN_REFLEN]; char buff[20+FN_REFLEN];
uint keynr,primary_key; uint keynr,primary_key;
sprintf(buff,"show keys from %s",table_name); sprintf(buff,"show keys from %s", result_table);
if (mysql_query(sock, buff)) if (mysql_query(sock, buff))
{ {
fprintf(stderr, "%s: Can't get keys for table '%s' (%s)\n", fprintf(stderr, "%s: Can't get keys for table %s (%s)\n",
my_progname, table, mysql_error(sock)); my_progname, result_table, mysql_error(sock));
if (path) if (path)
my_fclose(sql_file, MYF(MY_WME)); my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
@ -897,15 +911,15 @@ static uint getTableStructure(char *table, char* db)
putc(')', sql_file); putc(')', sql_file);
if (atoi(row[1])) /* Test if duplicate key */ if (atoi(row[1])) /* Test if duplicate key */
/* Duplicate allowed */ /* Duplicate allowed */
fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff)); fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff,0));
else if (keynr == primary_key) else if (keynr == primary_key)
fputs(",\n PRIMARY KEY (",sql_file); /* First UNIQUE is primary */ fputs(",\n PRIMARY KEY (",sql_file); /* First UNIQUE is primary */
else else
fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff)); fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff,0));
} }
else else
putc(',', sql_file); putc(',', sql_file);
fputs(quote_name(row[4],name_buff), sql_file); fputs(quote_name(row[4], name_buff, 0), sql_file);
if (row[7]) if (row[7])
fprintf(sql_file, " (%s)",row[7]); /* Sub key */ fprintf(sql_file, " (%s)",row[7]); /* Sub key */
} }
@ -916,23 +930,23 @@ static uint getTableStructure(char *table, char* db)
/* Get MySQL specific create options */ /* Get MySQL specific create options */
if (create_options) if (create_options)
{ {
sprintf(buff,"show table status like '%s'",table); sprintf(buff,"show table status like %s",result_table);
if (mysql_query(sock, buff)) if (mysql_query(sock, buff))
{ {
if (mysql_errno(sock) != ER_PARSE_ERROR) if (mysql_errno(sock) != ER_PARSE_ERROR)
{ /* If old MySQL version */ { /* If old MySQL version */
if (verbose) if (verbose)
fprintf(stderr, fprintf(stderr,
"-- Warning: Couldn't get status information for table '%s' (%s)\n", "-- Warning: Couldn't get status information for table %s (%s)\n",
table,mysql_error(sock)); result_table,mysql_error(sock));
} }
} }
else if (!(tableRes=mysql_store_result(sock)) || else if (!(tableRes=mysql_store_result(sock)) ||
!(row=mysql_fetch_row(tableRes))) !(row=mysql_fetch_row(tableRes)))
{ {
fprintf(stderr, fprintf(stderr,
"Error: Couldn't read status information for table '%s' (%s)\n", "Error: Couldn't read status information for table %s (%s)\n",
table,mysql_error(sock)); result_table,mysql_error(sock));
} }
else else
{ {
@ -1016,6 +1030,7 @@ static char *field_escape(char *to,const char *from,uint length)
static void dumpTable(uint numFields, char *table) static void dumpTable(uint numFields, char *table)
{ {
char query[QUERY_LENGTH], *end, buff[256],table_buff[NAME_LEN+3]; char query[QUERY_LENGTH], *end, buff[256],table_buff[NAME_LEN+3];
char *result_table, table_buff2[NAME_LEN*2+3], *opt_quoted_table;
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_FIELD *field; MYSQL_FIELD *field;
MYSQL_ROW row; MYSQL_ROW row;
@ -1023,6 +1038,8 @@ static void dumpTable(uint numFields, char *table)
if (verbose) if (verbose)
fprintf(stderr, "-- Sending SELECT query...\n"); fprintf(stderr, "-- Sending SELECT query...\n");
result_table= quote_name(table,table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
if (path) if (path)
{ {
char filename[FN_REFLEN], tmp_path[FN_REFLEN]; char filename[FN_REFLEN], tmp_path[FN_REFLEN];
@ -1049,7 +1066,7 @@ static void dumpTable(uint numFields, char *table)
end= add_load_option(end, lines_terminated, " LINES TERMINATED BY"); end= add_load_option(end, lines_terminated, " LINES TERMINATED BY");
*end= '\0'; *end= '\0';
sprintf(buff," FROM %s",quote_name(table,table_buff)); sprintf(buff," FROM %s", result_table);
end= strmov(end,buff); end= strmov(end,buff);
if (where) if (where)
end= strxmov(end, " WHERE ",where,NullS); end= strxmov(end, " WHERE ",where,NullS);
@ -1062,10 +1079,10 @@ static void dumpTable(uint numFields, char *table)
else else
{ {
if (!opt_xml) if (!opt_xml)
fprintf(md_result_file,"\n--\n-- Dumping data for table '%s'\n--\n", fprintf(md_result_file,"\n--\n-- Dumping data for table %s\n--\n",
table); result_table);
sprintf(query, "SELECT /*!40001 SQL_NO_CACHE */ * FROM %s", sprintf(query, "SELECT /*!40001 SQL_NO_CACHE */ * FROM %s",
quote_name(table,table_buff)); result_table);
if (where) if (where)
{ {
if (!opt_xml) if (!opt_xml)
@ -1092,18 +1109,17 @@ static void dumpTable(uint numFields, char *table)
fprintf(stderr, "-- Retrieving rows...\n"); fprintf(stderr, "-- Retrieving rows...\n");
if (mysql_num_fields(res) != numFields) if (mysql_num_fields(res) != numFields)
{ {
fprintf(stderr,"%s: Error in field count for table: '%s' ! Aborting.\n", fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n",
my_progname,table); my_progname, result_table);
safe_exit(EX_CONSCHECK); safe_exit(EX_CONSCHECK);
return; return;
} }
if (opt_disable_keys) if (opt_disable_keys)
fprintf(md_result_file,"/*!40000 ALTER TABLE %s DISABLE KEYS */;\n", fprintf(md_result_file, "\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n",
quote_name(table, table_buff)); opt_quoted_table);
if (opt_lock) if (opt_lock)
fprintf(md_result_file,"LOCK TABLES %s WRITE;\n", fprintf(md_result_file,"LOCK TABLES %s WRITE;\n", opt_quoted_table);
quote_name(table,table_buff));
total_length=net_buffer_length; /* Force row break */ total_length=net_buffer_length; /* Force row break */
row_break=0; row_break=0;
@ -1131,8 +1147,8 @@ static void dumpTable(uint numFields, char *table)
{ {
if (!(field = mysql_fetch_field(res))) if (!(field = mysql_fetch_field(res)))
{ {
sprintf(query,"%s: Not enough fields from table '%s'! Aborting.\n", sprintf(query,"%s: Not enough fields from table %s! Aborting.\n",
my_progname,table); my_progname, result_table);
fputs(query,stderr); fputs(query,stderr);
safe_exit(EX_CONSCHECK); safe_exit(EX_CONSCHECK);
return; return;
@ -1259,11 +1275,11 @@ static void dumpTable(uint numFields, char *table)
fflush(md_result_file); fflush(md_result_file);
if (mysql_errno(sock)) if (mysql_errno(sock))
{ {
sprintf(query,"%s: Error %d: %s when dumping table '%s' at row: %ld\n", sprintf(query,"%s: Error %d: %s when dumping table %s at row: %ld\n",
my_progname, my_progname,
mysql_errno(sock), mysql_errno(sock),
mysql_error(sock), mysql_error(sock),
table, result_table,
rownr); rownr);
fputs(query,stderr); fputs(query,stderr);
safe_exit(EX_CONSCHECK); safe_exit(EX_CONSCHECK);
@ -1273,7 +1289,7 @@ static void dumpTable(uint numFields, char *table)
fputs("UNLOCK TABLES;\n", md_result_file); fputs("UNLOCK TABLES;\n", md_result_file);
if (opt_disable_keys) if (opt_disable_keys)
fprintf(md_result_file,"/*!40000 ALTER TABLE %s ENABLE KEYS */;\n", fprintf(md_result_file,"/*!40000 ALTER TABLE %s ENABLE KEYS */;\n",
quote_name(table,table_buff)); opt_quoted_table);
if (opt_autocommit) if (opt_autocommit)
fprintf(md_result_file, "commit;\n"); fprintf(md_result_file, "commit;\n");
mysql_free_result(res); mysql_free_result(res);
@ -1415,7 +1431,7 @@ static int dump_all_tables_in_db(char *database)
{ {
char *table; char *table;
uint numrows; uint numrows;
char table_buff[NAME_LEN+3]; char table_buff[NAME_LEN*2+3];
if (init_dumping(database)) if (init_dumping(database))
return 1; return 1;
@ -1427,7 +1443,7 @@ static int dump_all_tables_in_db(char *database)
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (numrows=0 ; (table = getTableName(1)) ; numrows++) for (numrows=0 ; (table = getTableName(1)) ; numrows++)
{ {
dynstr_append(&query, quote_name(table, table_buff)); dynstr_append(&query, quote_name(table, table_buff, 1));
dynstr_append(&query, " READ /*!32311 LOCAL */,"); dynstr_append(&query, " READ /*!32311 LOCAL */,");
} }
if (numrows && mysql_real_query(sock, query.str, query.length-1)) if (numrows && mysql_real_query(sock, query.str, query.length-1))
@ -1459,7 +1475,7 @@ static int dump_all_tables_in_db(char *database)
static int dump_selected_tables(char *db, char **table_names, int tables) static int dump_selected_tables(char *db, char **table_names, int tables)
{ {
uint numrows; uint numrows;
char table_buff[NAME_LEN+3]; char table_buff[NAME_LEN*+3];
if (init_dumping(db)) if (init_dumping(db))
return 1; return 1;
@ -1471,7 +1487,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (i=0 ; i < tables ; i++) for (i=0 ; i < tables ; i++)
{ {
dynstr_append(&query, quote_name(table_names[i], table_buff)); dynstr_append(&query, quote_name(table_names[i], table_buff, 1));
dynstr_append(&query, " READ /*!32311 LOCAL */,"); dynstr_append(&query, " READ /*!32311 LOCAL */,");
} }
if (mysql_real_query(sock, query.str, query.length-1)) if (mysql_real_query(sock, query.str, query.length-1))

View File

@ -45,16 +45,15 @@ static char *opt_password=0, *current_user=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0,
*escaped=0, *opt_columns=0, *escaped=0, *opt_columns=0,
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
static uint opt_mysql_port=0; static uint opt_mysql_port= 0, opt_protocol= 0;
static my_string opt_mysql_unix_port=0; static my_string opt_mysql_unix_port=0;
static my_string opt_ignore_lines=0; static longlong opt_ignore_lines= -1;
static CHARSET_INFO *charset_info= &my_charset_latin1; static CHARSET_INFO *charset_info= &my_charset_latin1;
#include <sslopt-vars.h> #include <sslopt-vars.h>
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
static char *shared_memory_base_name=0; static char *shared_memory_base_name=0;
#endif #endif
static uint opt_protocol=0;
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
{ {
@ -97,7 +96,7 @@ static struct my_option my_long_options[] =
{"ignore", 'i', "If duplicate unique key was found, keep old row.", {"ignore", 'i', "If duplicate unique key was found, keep old row.",
(gptr*) &ignore, (gptr*) &ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &ignore, (gptr*) &ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.", {"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.",
(gptr*) &opt_ignore_lines, (gptr*) &opt_ignore_lines, 0, GET_STR, (gptr*) &opt_ignore_lines, (gptr*) &opt_ignore_lines, 0, GET_LL,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...",
(gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR,
@ -311,8 +310,9 @@ static int write_to_table(char *filename, MYSQL *sock)
" OPTIONALLY ENCLOSED BY"); " OPTIONALLY ENCLOSED BY");
end= add_load_option(end, escaped, " ESCAPED BY"); end= add_load_option(end, escaped, " ESCAPED BY");
end= add_load_option(end, lines_terminated, " LINES TERMINATED BY"); end= add_load_option(end, lines_terminated, " LINES TERMINATED BY");
if (opt_ignore_lines) if (opt_ignore_lines >= 0)
end= strmov(strmov(strmov(end, " IGNORE "), opt_ignore_lines), " LINES"); end= strmov(longlong10_to_str(opt_ignore_lines,
strmov(end, " IGNORE "),10), " LINES");
if (opt_columns) if (opt_columns)
end= strmov(strmov(strmov(end, " ("), opt_columns), ")"); end= strmov(strmov(strmov(end, " ("), opt_columns), ")");
*end= '\0'; *end= '\0';

View File

@ -1337,7 +1337,12 @@ then
if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so
then then
MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK
if expr "$CC" : ".*gcc.*"
then
with_named_thread="-pthread -lsocket -lnsl"
else
with_named_thread="-Kthread -lsocket -lnsl" with_named_thread="-Kthread -lsocket -lnsl"
fi
if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null
then then
AC_DEFINE(HAVE_UNIXWARE7_THREADS) AC_DEFINE(HAVE_UNIXWARE7_THREADS)
@ -1373,7 +1378,12 @@ then
if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so
then then
MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK
if expr "$CC" : ".*gcc.*"
then
with_named_thread="-pthread -lsocket -lnsl"
else
with_named_thread="-Kthread -lsocket -lnsl" with_named_thread="-Kthread -lsocket -lnsl"
fi
if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null
then then
AC_DEFINE(HAVE_UNIXWARE7_THREADS) AC_DEFINE(HAVE_UNIXWARE7_THREADS)

View File

@ -619,6 +619,8 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
unsigned long net_safe_read(MYSQL* mysql); unsigned long net_safe_read(MYSQL* mysql);
void mysql_once_init(void); void mysql_once_init(void);
extern my_bool server_inited;
#ifdef __NETWARE__ #ifdef __NETWARE__
#pragma pack(pop) /* restore alignment */ #pragma pack(pop) /* restore alignment */
#endif #endif

View File

@ -2658,6 +2658,12 @@ fseg_free_page_low(
ulint i; ulint i;
char errbuf[200]; char errbuf[200];
#ifdef __WIN__
dulint desm;
dulint segm;
#endif
ut_ad(seg_inode && mtr); ut_ad(seg_inode && mtr);
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) ==
FSEG_MAGIC_N_VALUE); FSEG_MAGIC_N_VALUE);
@ -2736,6 +2742,9 @@ fseg_free_page_low(
fprintf(stderr, fprintf(stderr,
"InnoDB: Dump of the segment inode: %s\n", errbuf); "InnoDB: Dump of the segment inode: %s\n", errbuf);
#ifndef __WIN__
fprintf(stderr, fprintf(stderr,
"InnoDB: Serious error: InnoDB is trying to free space %lu page %lu,\n" "InnoDB: Serious error: InnoDB is trying to free space %lu page %lu,\n"
"InnoDB: which does not belong to segment %lu %lu but belongs\n" "InnoDB: which does not belong to segment %lu %lu but belongs\n"
@ -2750,6 +2759,26 @@ fseg_free_page_low(
ut_dulint_get_low( ut_dulint_get_low(
mtr_read_dulint(seg_inode + FSEG_ID, MLOG_8BYTES, mtr))); mtr_read_dulint(seg_inode + FSEG_ID, MLOG_8BYTES, mtr)));
#else
/* More pedantic usage to avoid VC++ 6.0 compiler errors due to inline
function expansion issues */
desm = mtr_read_dulint(descr + XDES_ID, MLOG_8BYTES, mtr);
segm = mtr_read_dulint(seg_inode + FSEG_ID, MLOG_8BYTES, mtr);
fprintf(stderr,
"InnoDB: Serious error: InnoDB is trying to free space %lu page %lu,\n"
"InnoDB: which does not belong to segment %lu %lu but belongs\n"
"InnoDB: to segment %lu %lu.\n",
space, page,
ut_dulint_get_high(desm),
ut_dulint_get_low(desm),
ut_dulint_get_high(segm),
ut_dulint_get_low(segm));
#endif
fprintf(stderr, fprintf(stderr,
"InnoDB: If the InnoDB recovery crashes here, see section 6.1\n" "InnoDB: If the InnoDB recovery crashes here, see section 6.1\n"
"InnoDB: of http://www.innodb.com/ibman.html about forcing recovery.\n"); "InnoDB: of http://www.innodb.com/ibman.html about forcing recovery.\n");

View File

@ -78,7 +78,7 @@ char *get_tty_password(char *opt_message)
char *pos=to,*end=to+sizeof(to)-1; char *pos=to,*end=to+sizeof(to)-1;
int i=0; int i=0;
DBUG_ENTER("get_tty_password"); DBUG_ENTER("get_tty_password");
fprintf(stdout,opt_message ? opt_message : "Enter password: "); _cputs(opt_message ? opt_message : "Enter password: ");
for (;;) for (;;)
{ {
char tmp; char tmp;

View File

@ -26,7 +26,8 @@
static int fake_argc= 1; static int fake_argc= 1;
static char *fake_argv[]= {(char *)"", 0}; static char *fake_argv[]= {(char *)"", 0};
static const char *fake_groups[] = { "server", "embedded", 0 }; static const char *fake_groups[] = { "server", "embedded", 0 };
static char inited, org_my_init_done; static my_bool org_my_init_done;
my_bool server_inited;
#if defined (__WIN__) #if defined (__WIN__)
#include "../sql/mysqld.cpp" #include "../sql/mysqld.cpp"
@ -181,9 +182,9 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
/* Only call MY_INIT() if it hasn't been called before */ /* Only call MY_INIT() if it hasn't been called before */
if (!inited) if (!server_inited)
{ {
inited=1; server_inited=1;
org_my_init_done=my_init_done; org_my_init_done=my_init_done;
} }
if (!org_my_init_done) if (!org_my_init_done)

View File

@ -210,11 +210,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
db ? db : "(Null)", db ? db : "(Null)",
user ? user : "(Null)")); user ? user : "(Null)"));
if (mysql->options.methods_to_use == MYSQL_OPT_USE_REMOTE_CONNECTION) if (mysql->options.methods_to_use == MYSQL_OPT_USE_REMOTE_CONNECTION ||
cli_mysql_real_connect(mysql, host, user, (mysql->options.methods_to_use == MYSQL_OPT_GUESS_CONNECTION &&
passwd, db, port, unix_socket, client_flag); host && strcmp(host,LOCAL_HOST)))
if ((mysql->options.methods_to_use == MYSQL_OPT_GUESS_CONNECTION) &&
host && strcmp(host,LOCAL_HOST))
cli_mysql_real_connect(mysql, host, user, cli_mysql_real_connect(mysql, host, user,
passwd, db, port, unix_socket, client_flag); passwd, db, port, unix_socket, client_flag);
@ -277,7 +275,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
DBUG_RETURN(mysql); DBUG_RETURN(mysql);
error: error:
DBUG_PRINT("error",("message: %u (%s)",mysql->net.last_errno,mysql->net.last_error)); DBUG_PRINT("error",("message: %u (%s)", mysql->net.last_errno,
mysql->net.last_error));
{ {
/* Free alloced memory */ /* Free alloced memory */
my_bool free_me=mysql->free_me; my_bool free_me=mysql->free_me;
@ -289,6 +288,7 @@ error:
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/************************************************************************* /*************************************************************************
** Send a QUIT to the server and close the connection ** Send a QUIT to the server and close the connection
** If handle is alloced by mysql connect free it. ** If handle is alloced by mysql connect free it.

View File

@ -76,6 +76,8 @@ int mi_lock_database(MI_INFO *info, int lock_type)
} }
if (!count) if (!count)
{ {
DBUG_PRINT("info",("changed: %u w_locks: %u",
(uint) share->changed, share->w_locks));
if (share->changed && !share->w_locks) if (share->changed && !share->w_locks)
{ {
share->state.process= share->last_process=share->this_process; share->state.process= share->last_process=share->this_process;
@ -352,6 +354,8 @@ int _mi_writeinfo(register MI_INFO *info, uint operation)
int error,olderror; int error,olderror;
MYISAM_SHARE *share=info->s; MYISAM_SHARE *share=info->s;
DBUG_ENTER("_mi_writeinfo"); DBUG_ENTER("_mi_writeinfo");
DBUG_PRINT("info",("operation: %u tot_locks: %u", operation,
share->tot_locks));
error=0; error=0;
if (share->tot_locks == 0) if (share->tot_locks == 0)
@ -379,9 +383,7 @@ int _mi_writeinfo(register MI_INFO *info, uint operation)
my_errno=olderror; my_errno=olderror;
} }
else if (operation) else if (operation)
{
share->changed= 1; /* Mark keyfile changed */ share->changed= 1; /* Mark keyfile changed */
}
DBUG_RETURN(error); DBUG_RETURN(error);
} /* _mi_writeinfo */ } /* _mi_writeinfo */

View File

@ -778,6 +778,7 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite)
uchar *ptr=buff; uchar *ptr=buff;
uint i, keys= (uint) state->header.keys, uint i, keys= (uint) state->header.keys,
key_blocks=state->header.max_block_size; key_blocks=state->header.max_block_size;
DBUG_ENTER("mi_state_info_write");
memcpy_fixed(ptr,&state->header,sizeof(state->header)); memcpy_fixed(ptr,&state->header,sizeof(state->header));
ptr+=sizeof(state->header); ptr+=sizeof(state->header);
@ -828,10 +829,10 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite)
} }
if (pWrite & 1) if (pWrite & 1)
return my_pwrite(file,(char*) buff, (uint) (ptr-buff), 0L, DBUG_RETURN(my_pwrite(file,(char*) buff, (uint) (ptr-buff), 0L,
MYF(MY_NABP | MY_THREADSAFE)); MYF(MY_NABP | MY_THREADSAFE)));
else DBUG_RETURN(my_write(file, (char*) buff, (uint) (ptr-buff),
return my_write(file, (char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); MYF(MY_NABP)));
} }

View File

@ -743,6 +743,12 @@ static void uf_blob(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff,
{ {
ulong length=get_bits(bit_buff,rec->space_length_bits); ulong length=get_bits(bit_buff,rec->space_length_bits);
uint pack_length=(uint) (end-to)-mi_portable_sizeof_char_ptr; uint pack_length=(uint) (end-to)-mi_portable_sizeof_char_ptr;
if (bit_buff->blob_pos+length > bit_buff->end)
{
bit_buff->error=1;
bzero((byte*) to,(end-to));
return;
}
decode_bytes(rec,bit_buff,bit_buff->blob_pos,bit_buff->blob_pos+length); decode_bytes(rec,bit_buff,bit_buff->blob_pos,bit_buff->blob_pos+length);
_my_store_blob_length((byte*) to,pack_length,length); _my_store_blob_length((byte*) to,pack_length,length);
memcpy_fixed((char*) to+pack_length,(char*) &bit_buff->blob_pos, memcpy_fixed((char*) to+pack_length,(char*) &bit_buff->blob_pos,

View File

@ -96,7 +96,14 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec)
if (_mi_ft_cmp(info,i,oldrec, newrec)) if (_mi_ft_cmp(info,i,oldrec, newrec))
{ {
if ((int) i == info->lastinx) if ((int) i == info->lastinx)
{
/*
We are changeing the index we are reading on. Mark that
the index data has changed and we need to do a full search
when doing read-next
*/
key_changed|=HA_STATE_WRITTEN; key_changed|=HA_STATE_WRITTEN;
}
changed|=((ulonglong) 1 << i); changed|=((ulonglong) 1 << i);
if (_mi_ft_update(info,i,(char*) old_key,oldrec,newrec,pos)) if (_mi_ft_update(info,i,(char*) old_key,oldrec,newrec,pos))
goto err; goto err;
@ -123,25 +130,36 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec)
} }
/* /*
If we are running with external locking, we must update the index file If we are running with external locking, we must update the index file
that something has changed that something has changed.
*/ */
if (changed || !my_disable_locking) if (changed || !my_disable_locking)
key_changed|= HA_STATE_KEY_CHANGED; key_changed|= HA_STATE_CHANGED;
if (share->calc_checksum) if (share->calc_checksum)
{ {
info->checksum=(*share->calc_checksum)(info,newrec); info->checksum=(*share->calc_checksum)(info,newrec);
key_changed|= HA_STATE_KEY_CHANGED; /* Must update index file */ /* Store new checksum in index file header */
key_changed|= HA_STATE_CHANGED;
} }
{ {
/* Don't update index file if data file is not extended */ /*
Don't update index file if data file is not extended and no status
information changed
*/
MI_STATUS_INFO state; MI_STATUS_INFO state;
ha_rows org_split;
my_off_t org_delete_link;
memcpy((char*) &state, (char*) info->state, sizeof(state)); memcpy((char*) &state, (char*) info->state, sizeof(state));
org_split= share->state.split;
org_delete_link= share->state.dellink;
if ((*share->update_record)(info,pos,newrec)) if ((*share->update_record)(info,pos,newrec))
goto err; goto err;
if (!key_changed && if (!key_changed &&
memcmp((char*) &state, (char*) info->state, sizeof(state))) (memcmp((char*) &state, (char*) info->state, sizeof(state)) ||
key_changed|= HA_STATE_KEY_CHANGED; /* Must update index file */ org_split != share->state.split ||
org_delete_link != share->state.dellink))
key_changed|= HA_STATE_CHANGED; /* Must update index file */
} }
if (auto_key_changed) if (auto_key_changed)
update_auto_increment(info,newrec); update_auto_increment(info,newrec);
@ -165,7 +183,7 @@ err:
DBUG_PRINT("error",("key: %d errno: %d",i,my_errno)); DBUG_PRINT("error",("key: %d errno: %d",i,my_errno));
save_errno=my_errno; save_errno=my_errno;
if (changed) if (changed)
key_changed|= HA_STATE_KEY_CHANGED; key_changed|= HA_STATE_CHANGED;
if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_RECORD_FILE_FULL) if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_RECORD_FILE_FULL)
{ {
info->errkey= (int) i; info->errkey= (int) i;

View File

@ -1114,3 +1114,34 @@ a b
select * from t2; select * from t2;
a b a b
drop table t1,t2; drop table t1,t2;
create table t1 (x int not null, index(x)) type=bdb;
insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
select * from t1 where x <= 10 and x >= 7;
x
7
8
9
10
select * from t1 where x <= 10 and x >= 7 order by x;
x
7
8
9
10
select * from t1 where x <= 10 and x >= 7 order by x desc;
x
10
9
8
7
select * from t1 where x <= 8 and x >= 5 order by x desc;
x
8
7
6
5
select * from t1 where x < 8 and x > 5 order by x desc;
x
7
6
drop table t1;

View File

@ -91,39 +91,39 @@ show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
GRANT SELECT, INSERT, INSERT (a), REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost' GRANT SELECT, INSERT, INSERT (a), REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost'
REVOKE insert,insert (a) on t1 from mysqltest_1@localhost; REVOKE select,update,insert,insert (a) on t1 from mysqltest_1@localhost;
GRANT references on t1 to mysqltest_1@localhost;
show grants for mysqltest_1@localhost; show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
GRANT SELECT, REFERENCES, REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost' GRANT REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost'
GRANT select,references on t1 to mysqltest_1@localhost;
select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1";
table_priv column_priv table_priv column_priv
Select,References References Select,References References
grant all on test.* to user1@localhost with grant option; grant all on test.* to mysqltest_3@localhost with grant option;
revoke all on test.* from user1@localhost; revoke all on test.* from mysqltest_3@localhost;
show grants for user1@localhost; show grants for mysqltest_3@localhost;
Grants for user1@localhost Grants for mysqltest_3@localhost
GRANT USAGE ON *.* TO 'user1'@'localhost' GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost'
GRANT USAGE ON `test`.* TO 'user1'@'localhost' WITH GRANT OPTION GRANT USAGE ON `test`.* TO 'mysqltest_3'@'localhost' WITH GRANT OPTION
revoke grant option on test.* from user1@localhost; revoke grant option on test.* from mysqltest_3@localhost;
show grants for user1@localhost; show grants for mysqltest_3@localhost;
Grants for user1@localhost Grants for mysqltest_3@localhost
GRANT USAGE ON *.* TO 'user1'@'localhost' GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost'
grant all on test.t1 to user2@localhost with grant option; grant all on test.t1 to mysqltest_2@localhost with grant option;
revoke all on test.t1 from user2@localhost; revoke all on test.t1 from mysqltest_2@localhost;
show grants for user2@localhost; show grants for mysqltest_2@localhost;
Grants for user2@localhost Grants for mysqltest_2@localhost
GRANT USAGE ON *.* TO 'user2'@'localhost' GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost'
GRANT USAGE ON `test`.`t1` TO 'user2'@'localhost' WITH GRANT OPTION GRANT USAGE ON `test`.`t1` TO 'mysqltest_2'@'localhost' WITH GRANT OPTION
revoke grant option on test.t1 from user2@localhost; revoke grant option on test.t1 from mysqltest_2@localhost;
show grants for user2@localhost; show grants for mysqltest_2@localhost;
Grants for user2@localhost Grants for mysqltest_2@localhost
GRANT USAGE ON *.* TO 'user2'@'localhost' GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost'
delete from mysql.user where user='mysqltest_1'; delete from mysql.user where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
delete from mysql.db where user='mysqltest_1'; delete from mysql.db where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
delete from mysql.tables_priv where user='mysqltest_1'; delete from mysql.tables_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
delete from mysql.columns_priv where user='mysqltest_1'; delete from mysql.columns_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
flush privileges; flush privileges;
drop table t1; drop table t1;
GRANT FILE on mysqltest.* to mysqltest_1@localhost; GRANT FILE on mysqltest.* to mysqltest_1@localhost;

View File

@ -1,180 +1,180 @@
drop table if exists ti, tm; drop table if exists t1, t2;
create table ti (a int) type=innodb; create table t1 (a int) type=innodb;
create table tm (a int) type=myisam; create table t2 (a int) type=myisam;
reset master; reset master;
begin; begin;
insert into ti values(1); insert into t1 values(1);
insert into tm select * from ti; insert into t2 select * from t1;
commit; commit;
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; BEGIN master-bin.000001 79 Query 1 79 use `test`; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(1) master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(1)
master-bin.000001 178 Query 1 79 use ; insert into tm select * from ti master-bin.000001 178 Query 1 79 use `test`; insert into t2 select * from t1
master-bin.000001 244 Query 1 244 use ; COMMIT master-bin.000001 244 Query 1 244 use `test`; COMMIT
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(2); insert into t1 values(2);
insert into tm select * from ti; insert into t2 select * from t1;
rollback; rollback;
Warning: Some non-transactional changed tables couldn't be rolled back Warning: Some non-transactional changed tables couldn't be rolled back
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; BEGIN master-bin.000001 79 Query 1 79 use `test`; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(2) master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(2)
master-bin.000001 178 Query 1 79 use ; insert into tm select * from ti master-bin.000001 178 Query 1 79 use `test`; insert into t2 select * from t1
master-bin.000001 244 Query 1 244 use ; ROLLBACK master-bin.000001 244 Query 1 244 use `test`; ROLLBACK
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(3); insert into t1 values(3);
savepoint my_savepoint; savepoint my_savepoint;
insert into ti values(4); insert into t1 values(4);
insert into tm select * from ti; insert into t2 select * from t1;
rollback to savepoint my_savepoint; rollback to savepoint my_savepoint;
Warning: Some non-transactional changed tables couldn't be rolled back Warning: Some non-transactional changed tables couldn't be rolled back
commit; commit;
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; BEGIN master-bin.000001 79 Query 1 79 use `test`; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(3) master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(3)
master-bin.000001 178 Query 1 79 use ; savepoint my_savepoint master-bin.000001 178 Query 1 79 use `test`; savepoint my_savepoint
master-bin.000001 235 Query 1 79 use ; insert into ti values(4) master-bin.000001 235 Query 1 79 use `test`; insert into t1 values(4)
master-bin.000001 294 Query 1 79 use ; insert into tm select * from ti master-bin.000001 294 Query 1 79 use `test`; insert into t2 select * from t1
master-bin.000001 360 Query 1 79 use ; rollback to savepoint my_savepoint master-bin.000001 360 Query 1 79 use `test`; rollback to savepoint my_savepoint
master-bin.000001 429 Query 1 429 use ; COMMIT master-bin.000001 429 Query 1 429 use `test`; COMMIT
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(5); insert into t1 values(5);
savepoint my_savepoint; savepoint my_savepoint;
insert into ti values(6); insert into t1 values(6);
insert into tm select * from ti; insert into t2 select * from t1;
rollback to savepoint my_savepoint; rollback to savepoint my_savepoint;
Warning: Some non-transactional changed tables couldn't be rolled back Warning: Some non-transactional changed tables couldn't be rolled back
insert into ti values(7); insert into t1 values(7);
commit; commit;
select a from ti order by a; select a from t1 order by a;
a a
5 5
7 7
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; BEGIN master-bin.000001 79 Query 1 79 use `test`; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(5) master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(5)
master-bin.000001 178 Query 1 79 use ; savepoint my_savepoint master-bin.000001 178 Query 1 79 use `test`; savepoint my_savepoint
master-bin.000001 235 Query 1 79 use ; insert into ti values(6) master-bin.000001 235 Query 1 79 use `test`; insert into t1 values(6)
master-bin.000001 294 Query 1 79 use ; insert into tm select * from ti master-bin.000001 294 Query 1 79 use `test`; insert into t2 select * from t1
master-bin.000001 360 Query 1 79 use ; rollback to savepoint my_savepoint master-bin.000001 360 Query 1 79 use `test`; rollback to savepoint my_savepoint
master-bin.000001 429 Query 1 79 use ; insert into ti values(7) master-bin.000001 429 Query 1 79 use `test`; insert into t1 values(7)
master-bin.000001 488 Query 1 488 use ; COMMIT master-bin.000001 488 Query 1 488 use `test`; COMMIT
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
select get_lock("a",10); select get_lock("a",10);
get_lock("a",10) get_lock("a",10)
1 1
begin; begin;
insert into ti values(8); insert into t1 values(8);
insert into tm select * from ti; insert into t2 select * from t1;
select get_lock("a",10); select get_lock("a",10);
get_lock("a",10) get_lock("a",10)
1 1
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; BEGIN master-bin.000001 79 Query 1 79 use `test`; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(8) master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(8)
master-bin.000001 178 Query 1 79 use ; insert into tm select * from ti master-bin.000001 178 Query 1 79 use `test`; insert into t2 select * from t1
master-bin.000001 244 Query 1 244 use ; ROLLBACK master-bin.000001 244 Query 1 244 use `test`; ROLLBACK
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
insert into ti values(9); insert into t1 values(9);
insert into tm select * from ti; insert into t2 select * from t1;
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; insert into ti values(9) master-bin.000001 79 Query 1 79 use `test`; insert into t1 values(9)
master-bin.000001 138 Query 1 138 use ; insert into tm select * from ti master-bin.000001 138 Query 1 138 use `test`; insert into t2 select * from t1
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
insert into ti values(10); insert into t1 values(10);
begin; begin;
insert into tm select * from ti; insert into t2 select * from t1;
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; insert into ti values(10) master-bin.000001 79 Query 1 79 use `test`; insert into t1 values(10)
master-bin.000001 139 Query 1 139 use ; insert into tm select * from ti master-bin.000001 139 Query 1 139 use `test`; insert into t2 select * from t1
insert into ti values(11); insert into t1 values(11);
commit; commit;
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; insert into ti values(10) master-bin.000001 79 Query 1 79 use `test`; insert into t1 values(10)
master-bin.000001 139 Query 1 139 use ; insert into tm select * from ti master-bin.000001 139 Query 1 139 use `test`; insert into t2 select * from t1
master-bin.000001 205 Query 1 205 use ; BEGIN master-bin.000001 205 Query 1 205 use `test`; BEGIN
master-bin.000001 245 Query 1 205 use ; insert into ti values(11) master-bin.000001 245 Query 1 205 use `test`; insert into t1 values(11)
master-bin.000001 305 Query 1 305 use ; COMMIT master-bin.000001 305 Query 1 305 use `test`; COMMIT
alter table tm type=INNODB; alter table t2 type=INNODB;
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(12); insert into t1 values(12);
insert into tm select * from ti; insert into t2 select * from t1;
commit; commit;
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; BEGIN master-bin.000001 79 Query 1 79 use `test`; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(12) master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(12)
master-bin.000001 179 Query 1 79 use ; insert into tm select * from ti master-bin.000001 179 Query 1 79 use `test`; insert into t2 select * from t1
master-bin.000001 245 Query 1 245 use ; COMMIT master-bin.000001 245 Query 1 245 use `test`; COMMIT
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(13); insert into t1 values(13);
insert into tm select * from ti; insert into t2 select * from t1;
rollback; rollback;
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(14); insert into t1 values(14);
savepoint my_savepoint; savepoint my_savepoint;
insert into ti values(15); insert into t1 values(15);
insert into tm select * from ti; insert into t2 select * from t1;
rollback to savepoint my_savepoint; rollback to savepoint my_savepoint;
commit; commit;
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; BEGIN master-bin.000001 79 Query 1 79 use `test`; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(14) master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(14)
master-bin.000001 179 Query 1 179 use ; COMMIT master-bin.000001 179 Query 1 179 use `test`; COMMIT
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(16); insert into t1 values(16);
savepoint my_savepoint; savepoint my_savepoint;
insert into ti values(17); insert into t1 values(17);
insert into tm select * from ti; insert into t2 select * from t1;
rollback to savepoint my_savepoint; rollback to savepoint my_savepoint;
insert into ti values(18); insert into t1 values(18);
commit; commit;
select a from ti order by a; select a from t1 order by a;
a a
16 16
18 18
show binlog events from 79; show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 79 Query 1 79 use ; BEGIN master-bin.000001 79 Query 1 79 use `test`; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(16) master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(16)
master-bin.000001 179 Query 1 79 use ; insert into ti values(18) master-bin.000001 179 Query 1 79 use `test`; insert into t1 values(18)
master-bin.000001 239 Query 1 239 use ; COMMIT master-bin.000001 239 Query 1 239 use `test`; COMMIT
drop table ti,tm; drop table t1,t2;

View File

@ -376,6 +376,28 @@ explain select * from t1 use index() where c=1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
drop table t1,t2; drop table t1,t2;
create table t1 (a int not null auto_increment primary key, b varchar(255));
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
update t1 set b=repeat(left(b,1),200) where a=1;
delete from t1 where (a & 1)= 0;
update t1 set b=repeat('e',200) where a=1;
flush tables;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
update t1 set b=repeat(left(b,1),255) where a between 1 and 5;
update t1 set b=repeat(left(b,1),10) where a between 32 and 43;
update t1 set b=repeat(left(b,1),2) where a between 64 and 66;
update t1 set b=repeat(left(b,1),65) where a between 67 and 70;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
insert into t1 (b) values (repeat('z',100));
update t1 set b="test" where left(b,1) > 'n';
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM; CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM;
ERROR 42000: This version of MySQL doesn't yet support 'RTREE INDEX' ERROR 42000: This version of MySQL doesn't yet support 'RTREE INDEX'
create table t1 (a int, b varchar(200), c text not null) checksum=1; create table t1 (a int, b varchar(200), c text not null) checksum=1;

View File

@ -253,4 +253,23 @@ explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref y y 5 const 1 Using where 1 SIMPLE t1 ref y y 5 const 1 Using where
1 SIMPLE t2 range x x 5 NULL 2 Using where 1 SIMPLE t2 range x x 5 NULL 2 Using where
explain select count(*) from t1 where x in (1);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range x x 5 NULL 1 Using where; Using index
explain select count(*) from t1 where x in (1,2);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range x x 5 NULL 2 Using where; Using index
drop table t1; drop table t1;
CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1), KEY i2 (key1));
INSERT INTO t1 VALUES (0),(0),(1),(1);
CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya));
INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
table type possible_keys key key_len ref rows Extra
t2 ref j1 j1 4 const 1 Using where; Using index
t1 ALL i1,i2 NULL NULL NULL 4 Range checked for each record (index map: 3)
explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
table type possible_keys key key_len ref rows Extra
t2 ref j1 j1 4 const 1 Using where; Using index
t1 ALL i2 NULL NULL NULL 4 Range checked for each record (index map: 2)
DROP TABLE t1,t2;

View File

@ -776,3 +776,16 @@ select * from t1;
select * from t2; select * from t2;
select * from t2; select * from t2;
drop table t1,t2; drop table t1,t2;
#
# The bug #971
#
create table t1 (x int not null, index(x)) type=bdb;
insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
select * from t1 where x <= 10 and x >= 7;
select * from t1 where x <= 10 and x >= 7 order by x;
select * from t1 where x <= 10 and x >= 7 order by x desc;
select * from t1 where x <= 8 and x >= 5 order by x desc;
select * from t1 where x < 8 and x > 5 order by x desc;
drop table t1;

View File

@ -65,24 +65,24 @@ show grants for mysqltest_1@localhost;
select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1";
REVOKE select (a), update on t1 from mysqltest_1@localhost; REVOKE select (a), update on t1 from mysqltest_1@localhost;
show grants for mysqltest_1@localhost; show grants for mysqltest_1@localhost;
REVOKE insert,insert (a) on t1 from mysqltest_1@localhost; REVOKE select,update,insert,insert (a) on t1 from mysqltest_1@localhost;
GRANT references on t1 to mysqltest_1@localhost;
show grants for mysqltest_1@localhost; show grants for mysqltest_1@localhost;
GRANT select,references on t1 to mysqltest_1@localhost;
select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1";
grant all on test.* to user1@localhost with grant option; grant all on test.* to mysqltest_3@localhost with grant option;
revoke all on test.* from user1@localhost; revoke all on test.* from mysqltest_3@localhost;
show grants for user1@localhost; show grants for mysqltest_3@localhost;
revoke grant option on test.* from user1@localhost; revoke grant option on test.* from mysqltest_3@localhost;
show grants for user1@localhost; show grants for mysqltest_3@localhost;
grant all on test.t1 to user2@localhost with grant option; grant all on test.t1 to mysqltest_2@localhost with grant option;
revoke all on test.t1 from user2@localhost; revoke all on test.t1 from mysqltest_2@localhost;
show grants for user2@localhost; show grants for mysqltest_2@localhost;
revoke grant option on test.t1 from user2@localhost; revoke grant option on test.t1 from mysqltest_2@localhost;
show grants for user2@localhost; show grants for mysqltest_2@localhost;
delete from mysql.user where user='mysqltest_1'; delete from mysql.user where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
delete from mysql.db where user='mysqltest_1'; delete from mysql.db where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
delete from mysql.tables_priv where user='mysqltest_1'; delete from mysql.tables_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
delete from mysql.columns_priv where user='mysqltest_1'; delete from mysql.columns_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
flush privileges; flush privileges;
drop table t1; drop table t1;

View File

@ -1,83 +1,86 @@
# Check that binlog is ok when a transaction mixes updates to InnoDB and # Check that binlog is ok when a transaction mixes updates to InnoDB and
# MyISAM. It would be nice to make this a replication test, but in 4.0 the slave # MyISAM.
# is always with --skip-innodb in the testsuite. I (Guilhem) however did some # It would be nice to make this a replication test, but in 4.0 the
# tests manually on a slave; tables are replicated fine and Exec_master_log_pos # slave is always with --skip-innodb in the testsuite. I (Guilhem) however
# advances as expected. # did some tests manually on a slave; tables are replicated fine and
# Exec_master_log_pos advances as expected.
-- source include/have_innodb.inc -- source include/have_innodb.inc
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
connect (con2,localhost,root,,); connect (con2,localhost,root,,);
connection con1; connection con1;
create table t1 (a int) type=innodb;
drop table if exists ti, tm; create table t2 (a int) type=myisam;
create table ti (a int) type=innodb;
create table tm (a int) type=myisam;
reset master; reset master;
begin; begin;
insert into ti values(1); insert into t1 values(1);
insert into tm select * from ti; insert into t2 select * from t1;
commit; commit;
show binlog events from 79; show binlog events from 79;
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(2); insert into t1 values(2);
insert into tm select * from ti; insert into t2 select * from t1;
# should say some changes to non-transactional tables couldn't be rolled back # should say some changes to non-transact1onal tables couldn't be rolled back
--error 1196 --error 1196
rollback; rollback;
show binlog events from 79; show binlog events from 79;
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(3); insert into t1 values(3);
savepoint my_savepoint; savepoint my_savepoint;
insert into ti values(4); insert into t1 values(4);
insert into tm select * from ti; insert into t2 select * from t1;
--error 1196 --error 1196
rollback to savepoint my_savepoint; rollback to savepoint my_savepoint;
commit; commit;
show binlog events from 79; show binlog events from 79;
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(5); insert into t1 values(5);
savepoint my_savepoint; savepoint my_savepoint;
insert into ti values(6); insert into t1 values(6);
insert into tm select * from ti; insert into t2 select * from t1;
--error 1196 --error 1196
rollback to savepoint my_savepoint; rollback to savepoint my_savepoint;
insert into ti values(7); insert into t1 values(7);
commit; commit;
select a from ti order by a; # check that savepoints work :) select a from t1 order by a; # check that savepoints work :)
show binlog events from 79; show binlog events from 79;
# and when ROLLBACK is not explicit? # and when ROLLBACK is not explicit?
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
select get_lock("a",10); select get_lock("a",10);
begin; begin;
insert into ti values(8); insert into t1 values(8);
insert into tm select * from ti; insert into t2 select * from t1;
disconnect con1; disconnect con1;
connection con2; connection con2;
@ -89,87 +92,87 @@ connection con2;
select get_lock("a",10); select get_lock("a",10);
show binlog events from 79; show binlog events from 79;
# and when not in a transaction? # and when not in a transact1on?
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
insert into ti values(9); insert into t1 values(9);
insert into tm select * from ti; insert into t2 select * from t1;
show binlog events from 79; show binlog events from 79;
# Check that when the query updating the MyISAM table is the first in the # Check that when the query updat1ng the MyISAM table is the first in the
# transaction, we log it immediately. # transact1on, we log it immediately.
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
insert into ti values(10); # first make ti non-empty insert into t1 values(10); # first make t1 non-empty
begin; begin;
insert into tm select * from ti; insert into t2 select * from t1;
show binlog events from 79; show binlog events from 79;
insert into ti values(11); insert into t1 values(11);
commit; commit;
show binlog events from 79; show binlog events from 79;
# Check that things work like before this BEGIN/ROLLBACK code was added, when tm # Check that things work like before this BEGIN/ROLLBACK code was added,
# is INNODB # when t2 is INNODB
alter table tm type=INNODB; alter table t2 type=INNODB;
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(12); insert into t1 values(12);
insert into tm select * from ti; insert into t2 select * from t1;
commit; commit;
show binlog events from 79; show binlog events from 79;
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(13); insert into t1 values(13);
insert into tm select * from ti; insert into t2 select * from t1;
rollback; rollback;
show binlog events from 79; show binlog events from 79;
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(14); insert into t1 values(14);
savepoint my_savepoint; savepoint my_savepoint;
insert into ti values(15); insert into t1 values(15);
insert into tm select * from ti; insert into t2 select * from t1;
rollback to savepoint my_savepoint; rollback to savepoint my_savepoint;
commit; commit;
show binlog events from 79; show binlog events from 79;
delete from ti; delete from t1;
delete from tm; delete from t2;
reset master; reset master;
begin; begin;
insert into ti values(16); insert into t1 values(16);
savepoint my_savepoint; savepoint my_savepoint;
insert into ti values(17); insert into t1 values(17);
insert into tm select * from ti; insert into t2 select * from t1;
rollback to savepoint my_savepoint; rollback to savepoint my_savepoint;
insert into ti values(18); insert into t1 values(18);
commit; commit;
select a from ti order by a; # check that savepoints work :) select a from t1 order by a; # check that savepoints work :)
show binlog events from 79; show binlog events from 79;
drop table ti,tm; drop table t1,t2;

View File

@ -362,6 +362,40 @@ explain select * from t1 where c=1;
explain select * from t1 use index() where c=1; explain select * from t1 use index() where c=1;
drop table t1,t2; drop table t1,t2;
#
# Test bug when updating a split dynamic row where keys are not changed
#
create table t1 (a int not null auto_increment primary key, b varchar(255));
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
update t1 set b=repeat(left(b,1),200) where a=1;
delete from t1 where (a & 1)= 0;
update t1 set b=repeat('e',200) where a=1;
flush tables;
check table t1;
#
# check updating with keys
#
disable_query_log;
let $1 = 100;
while ($1)
{
eval insert into t1 (b) values (repeat(char(($1 & 32)+65), $1));
dec $1;
}
enable_query_log;
update t1 set b=repeat(left(b,1),255) where a between 1 and 5;
update t1 set b=repeat(left(b,1),10) where a between 32 and 43;
update t1 set b=repeat(left(b,1),2) where a between 64 and 66;
update t1 set b=repeat(left(b,1),65) where a between 67 and 70;
check table t1;
insert into t1 (b) values (repeat('z',100));
update t1 set b="test" where left(b,1) > 'n';
check table t1;
drop table t1;
# #
# Test RTREE index # Test RTREE index
# #
@ -380,4 +414,3 @@ checksum table t1, t2, t3;
checksum table t1, t2, t3 extended; checksum table t1, t2, t3 extended;
#show table status; #show table status;
drop table t1,t2; drop table t1,t2;

View File

@ -201,5 +201,19 @@ explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1
# equation propagation # equation propagation
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
# testing IN
explain select count(*) from t1 where x in (1);
explain select count(*) from t1 where x in (1,2);
drop table t1; drop table t1;
#
# bug #1172
#
CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1), KEY i2 (key1));
INSERT INTO t1 VALUES (0),(0),(1),(1);
CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya));
INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
DROP TABLE t1,t2;

View File

@ -13,8 +13,8 @@ DEBUG=0
SILENT=0 SILENT=0
SUFFIX="" SUFFIX=""
DIRNAME="" DIRNAME=""
OUTTAR=0 OUTTAR="0"
OUTZIP=0 OUTZIP="0"
# #
# This script must run from MySQL top directory # This script must run from MySQL top directory
@ -114,8 +114,27 @@ done
# Convert argument file from unix to DOS text # Convert argument file from unix to DOS text
# #
unix_to_dos() if [ `which recode` ]
{ then
print_debug "Using 'recode' to convert from unix to dos text"
unix_to_dos()
{
for arg do
print_debug "Replacing LF -> CRLF from '$arg'"
chmod u+w $arg
recode lat1..ibmpc $arg
done
}
else
print_debug "Using 'sed' to convert from unix to dos text"
unix_to_dos()
{
for arg do for arg do
print_debug "Replacing LF -> CRLF from '$arg'" print_debug "Replacing LF -> CRLF from '$arg'"
@ -123,7 +142,9 @@ unix_to_dos()
rm -f $arg rm -f $arg
mv $arg.tmp $arg mv $arg.tmp $arg
done done
} }
fi
# #
@ -363,8 +384,10 @@ which_1 ()
# Create the result zip/tar file # Create the result zip/tar file
# #
if [ [ "$OUTTAR" = "0" ] && [ "$OUTZIP" = "0" ] ]; then if [ "$OUTTAR" = "0" ]; then
if [ "$OUTZIP" = "0" ]; then
OUTZIP=1 OUTZIP=1
fi
fi fi
set_tarzip_options() set_tarzip_options()

View File

@ -33,6 +33,7 @@ parse_arguments() {
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--skip-name-resolve) ip_only=1 ;;
--verbose) verbose=1 ;; --verbose) verbose=1 ;;
--rpm) in_rpm=1 ;; --rpm) in_rpm=1 ;;
--windows) windows=1 ;; --windows) windows=1 ;;
@ -166,6 +167,12 @@ then
fi fi
fi fi
if test "$ip_only" -eq 1
then
ip=`echo "$resolved" | awk '/ /{print $6}'`
hostname=$ip
fi
# Create database directories mysql & test # Create database directories mysql & test
if test ! -d $ldata; then mkdir $ldata; chmod 700 $ldata ; fi if test ! -d $ldata; then mkdir $ldata; chmod 700 $ldata ; fi

View File

@ -1433,6 +1433,8 @@ int ha_berkeley::index_read(byte * buf, const byte * key,
} }
if (key_len == key_info->key_length) if (key_len == key_info->key_length)
{ {
if (find_flag == HA_READ_AFTER_KEY)
key_info->handler.bdb_return_if_eq= 1;
error=read_row(cursor->c_get(cursor, pack_key(&last_key, error=read_row(cursor->c_get(cursor, pack_key(&last_key,
active_index, active_index,
key_buff, key_buff,
@ -1441,6 +1443,7 @@ int ha_berkeley::index_read(byte * buf, const byte * key,
(find_flag == HA_READ_KEY_EXACT ? (find_flag == HA_READ_KEY_EXACT ?
DB_SET : DB_SET_RANGE)), DB_SET : DB_SET_RANGE)),
(char*) buf, active_index, &row, (DBT*) 0, 0); (char*) buf, active_index, &row, (DBT*) 0, 0);
key_info->handler.bdb_return_if_eq= 0;
} }
else else
{ {

View File

@ -3821,7 +3821,7 @@ master-ssl",
(gptr*) &master_ssl_cipher, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG, (gptr*) &master_ssl_cipher, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"myisam-recover", OPT_MYISAM_RECOVER, {"myisam-recover", OPT_MYISAM_RECOVER,
"Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP or FORCE.", "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP, FORCE or QUICK.",
(gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0, (gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0,
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (gptr*) &locked_in_memory, {"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (gptr*) &locked_in_memory,

View File

@ -716,7 +716,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables,
param.range_count, param.range_count,
found_records)+ found_records)+
(double) found_records / TIME_FOR_COMPARE); (double) found_records / TIME_FOR_COMPARE);
if (read_time > found_read_time) if (read_time > found_read_time && found_records != HA_POS_ERROR)
{ {
read_time=found_read_time; read_time=found_read_time;
records=found_records; records=found_records;

View File

@ -1690,6 +1690,7 @@ class GRANT_TABLE :public Sql_alloc
public: public:
char *host,*db,*user,*tname, *hash_key; char *host,*db,*user,*tname, *hash_key;
ulong privs, cols; ulong privs, cols;
ulong sort;
uint key_length; uint key_length;
HASH hash_columns; HASH hash_columns;
GRANT_TABLE (const char *h, const char *d,const char *u, const char *t, GRANT_TABLE (const char *h, const char *d,const char *u, const char *t,
@ -1699,6 +1700,7 @@ public:
host = strdup_root(&memex,h); host = strdup_root(&memex,h);
db = strdup_root(&memex,d); db = strdup_root(&memex,d);
user = strdup_root(&memex,u); user = strdup_root(&memex,u);
sort= get_sort(3,host,db,user);
tname= strdup_root(&memex,t); tname= strdup_root(&memex,t);
if (lower_case_table_names) if (lower_case_table_names)
{ {
@ -1721,7 +1723,8 @@ public:
user = get_field(&memex,form->field[2]); user = get_field(&memex,form->field[2]);
if (!user) if (!user)
user=(char*) ""; user=(char*) "";
tname = get_field(&memex,form->field[3]); sort= get_sort(3,host,db,user);
tname= get_field(&memex,form->field[3]);
if (!host || !db || !tname) if (!host || !db || !tname)
{ {
/* Wrong table row; Ignore it */ /* Wrong table row; Ignore it */
@ -1830,10 +1833,11 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip,
} }
else else
{ {
if ((host && !wild_case_compare(&my_charset_latin1, if (((host && !wild_case_compare(&my_charset_latin1,
host,grant_table->host)) || host,grant_table->host)) ||
(ip && !wild_case_compare(&my_charset_latin1, (ip && !wild_case_compare(&my_charset_latin1,
ip,grant_table->host))) ip,grant_table->host))) &&
(!found || found->sort < grant_table->sort))
found=grant_table; // Host ok found=grant_table; // Host ok
} }
} }
@ -3174,17 +3178,19 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
if ((table_access | grant_table->cols) != 0) if ((table_access | grant_table->cols) != 0)
{ {
String global(buff,sizeof(buff),&my_charset_latin1); String global(buff,sizeof(buff),&my_charset_latin1);
ulong test_access= (table_access | grant_table->cols) & ~GRANT_ACL;
global.length(0); global.length(0);
global.append("GRANT ",6); global.append("GRANT ",6);
if (test_all_bits(table_access, (TABLE_ACLS & ~GRANT_ACL))) if (test_all_bits(table_access, (TABLE_ACLS & ~GRANT_ACL)))
global.append("ALL PRIVILEGES",14); global.append("ALL PRIVILEGES",14);
else if (!(table_access & ~GRANT_ACL)) else if (!test_access)
global.append("USAGE",5); global.append("USAGE",5);
else else
{ {
int found= 0; int found= 0;
ulong j,test_access= (table_access | grant_table->cols) & ~GRANT_ACL; ulong j;
for (counter= 0, j= SELECT_ACL; j <= TABLE_ACLS; counter++, j<<= 1) for (counter= 0, j= SELECT_ACL; j <= TABLE_ACLS; counter++, j<<= 1)
{ {

View File

@ -623,7 +623,6 @@ check_connection(THD *thd)
thd->ip= 0; thd->ip= 0;
bzero((char*) &thd->remote, sizeof(struct sockaddr)); bzero((char*) &thd->remote, sizeof(struct sockaddr));
} }
/* Ensure that wrong hostnames doesn't cause buffer overflows */
vio_keepalive(net->vio, TRUE); vio_keepalive(net->vio, TRUE);
ulong pkt_len= 0; ulong pkt_len= 0;
@ -1882,9 +1881,7 @@ mysql_execute_command(THD *thd)
res = mysql_preload_keys(thd, tables); res = mysql_preload_keys(thd, tables);
break; break;
} }
#ifdef HAVE_REPLICATION
#ifndef EMBEDDED_LIBRARY
case SQLCOM_CHANGE_MASTER: case SQLCOM_CHANGE_MASTER:
{ {
if (check_global_access(thd, SUPER_ACL)) if (check_global_access(thd, SUPER_ACL))
@ -1921,8 +1918,7 @@ mysql_execute_command(THD *thd)
else else
res = load_master_data(thd); res = load_master_data(thd);
break; break;
#endif /* EMBEDDED_LIBRARY */ #endif /* HAVE_REPLICATION */
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
case SQLCOM_SHOW_INNODB_STATUS: case SQLCOM_SHOW_INNODB_STATUS:
{ {
@ -1932,8 +1928,7 @@ mysql_execute_command(THD *thd)
break; break;
} }
#endif #endif
#ifdef HAVE_REPLICATION
#ifndef EMBEDDED_LIBRARY
case SQLCOM_LOAD_MASTER_TABLE: case SQLCOM_LOAD_MASTER_TABLE:
{ {
if (!tables->db) if (!tables->db)
@ -1965,7 +1960,7 @@ mysql_execute_command(THD *thd)
UNLOCK_ACTIVE_MI; UNLOCK_ACTIVE_MI;
break; break;
} }
#endif /* EMBEDDED_LIBRARY */ #endif /* HAVE_REPLICATION */
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
{ {
@ -2082,7 +2077,7 @@ mysql_execute_command(THD *thd)
res = mysql_create_index(thd, tables, lex->key_list); res = mysql_create_index(thd, tables, lex->key_list);
break; break;
#ifndef EMBEDDED_LIBRARY #ifdef HAVE_REPLICATION
case SQLCOM_SLAVE_START: case SQLCOM_SLAVE_START:
{ {
LOCK_ACTIVE_MI; LOCK_ACTIVE_MI;
@ -2115,7 +2110,7 @@ mysql_execute_command(THD *thd)
UNLOCK_ACTIVE_MI; UNLOCK_ACTIVE_MI;
break; break;
} }
#endif #endif /* HAVE_REPLICATION */
case SQLCOM_ALTER_TABLE: case SQLCOM_ALTER_TABLE:
#if defined(DONT_ALLOW_SHOW_COMMANDS) #if defined(DONT_ALLOW_SHOW_COMMANDS)

View File

@ -158,7 +158,7 @@ static void copy_sum_funcs(Item_sum **func_ptr);
static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab); static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab);
static bool init_sum_functions(Item_sum **func, Item_sum **end); static bool init_sum_functions(Item_sum **func, Item_sum **end);
static bool update_sum_func(Item_sum **func); static bool update_sum_func(Item_sum **func);
static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, static void select_describe(JOIN *join, bool need_tmp_table,bool need_order,
bool distinct, const char *message=NullS); bool distinct, const char *message=NullS);
@ -2178,6 +2178,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
add_key_field(key_fields,*and_level, add_key_field(key_fields,*and_level,
((Item_field*) (cond_func->key_item()->real_item()))->field, 0, ((Item_field*) (cond_func->key_item()->real_item()))->field, 0,
cond_func->arguments()+1, cond_func->argument_count()-1, cond_func->arguments()+1, cond_func->argument_count()-1,
#endif
usable_tables); usable_tables);
break; break;
case Item_func::OPTIMIZE_OP: case Item_func::OPTIMIZE_OP:
@ -3337,13 +3338,30 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
join->best_positions[i].records_read && join->best_positions[i].records_read &&
!(join->select_options & OPTION_FOUND_ROWS))) !(join->select_options & OPTION_FOUND_ROWS)))
{ {
/* Join with outer join condition */
COND *orig_cond=sel->cond;
sel->cond=and_conds(sel->cond,tab->on_expr);
if (sel->test_quick_select(tab->keys, if (sel->test_quick_select(tab->keys,
used_tables & ~ current_map, used_tables & ~ current_map,
(join->select_options & (join->select_options &
OPTION_FOUND_ROWS ? OPTION_FOUND_ROWS ?
HA_POS_ERROR : HA_POS_ERROR :
join->unit->select_limit_cnt)) < 0) join->unit->select_limit_cnt)) < 0)
DBUG_RETURN(1); // Impossible range { /* before reporting "Impossible WHERE" for the whole query
we have to check isn't it only "impossible ON" instead */
sel->cond=orig_cond;
if (!tab->on_expr ||
sel->test_quick_select(tab->keys,
used_tables & ~ current_map,
(join->select_options &
OPTION_FOUND_ROWS ?
HA_POS_ERROR :
join->thd->select_limit)) < 0)
DBUG_RETURN(1); // Impossible WHERE
}
else
sel->cond=orig_cond;
/* Fix for EXPLAIN */ /* Fix for EXPLAIN */
if (sel->quick) if (sel->quick)
join->best_positions[i].records_read= sel->quick->records; join->best_positions[i].records_read= sel->quick->records;

View File

@ -3,6 +3,10 @@
%define mysqld_user mysql %define mysqld_user mysql
%define server_suffix -standard %define server_suffix -standard
# We don't package all files installed into the build root by intention -
# See BUG#998 for details.
%define _unpackaged_files_terminate_build 0
%define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com %define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com
Name: MySQL Name: MySQL
@ -562,18 +566,26 @@ fi
%files embedded %files embedded
%attr(644, root, root) %{_libdir}/mysql/libmysqld.a %attr(644, root, root) %{_libdir}/mysql/libmysqld.a
# The spec file changelog only includes changes made to the spec file
# itself
%changelog %changelog
* Fri Aug 29 2003 Lenz Grimmer <lenz@mysql.com>
- Fixed BUG 1162 (removed macro names from the changelog)
- Really fixed BUG 998 (disable the checking for installed but
unpackaged files)
* Tue Aug 05 2003 Lenz Grimmer <lenz@mysql.com> * Tue Aug 05 2003 Lenz Grimmer <lenz@mysql.com>
- Fixed BUG#959 (libmysqld not being compiled properly) - Fixed BUG 959 (libmysqld not being compiled properly)
- Fixed BUG#998 (RPM build errors): added missing files to the - Fixed BUG 998 (RPM build errors): added missing files to the
distribution (mysql_fix_extensions, mysql_tableinfo, mysqldumpslow, distribution (mysql_fix_extensions, mysql_tableinfo, mysqldumpslow,
mysql_fix_privilege_tables.1), removed "-n" from %install section. mysql_fix_privilege_tables.1), removed "-n" from install section.
* Wed Jul 09 2003 Lenz Grimmer <lenz@mysql.com> * Wed Jul 09 2003 Lenz Grimmer <lenz@mysql.com>
- removed the GIF Icon (file was not included in the sources anyway) - removed the GIF Icon (file was not included in the sources anyway)
- removed unused variable %shared_lib_version - removed unused variable shared_lib_version
- do not run automake before building the standard binary - do not run automake before building the standard binary
(should not be necessary) (should not be necessary)
- add server suffix '-standard' to standard binary (to be in line - add server suffix '-standard' to standard binary (to be in line
@ -594,7 +606,7 @@ fi
* Mon Mar 10 2003 Lenz Grimmer <lenz@mysql.com> * Mon Mar 10 2003 Lenz Grimmer <lenz@mysql.com>
- added missing file mysql_secure_installation to server subpackage - added missing file mysql_secure_installation to server subpackage
(bug #141) (BUG 141)
* Tue Feb 11 2003 Lenz Grimmer <lenz@mysql.com> * Tue Feb 11 2003 Lenz Grimmer <lenz@mysql.com>