Commit 91cb248a authored by unknown's avatar unknown

Merge hholzgraefe@bk-internal.mysql.com:/home/bk/mysql-5.0

into  mysql.com:/home/hartmut/projects/mysql/dev/5.0

parents 651134cf a5dd3d5d
......@@ -10,7 +10,7 @@ prefix_configs="--prefix=/usr/local/mysql"
just_print=
just_configure=
full_debug=
if test -n $MYSQL_BUILD_PREFIX
if test ! -z $MYSQL_BUILD_PREFIX
then
prefix_configs="--prefix=$MYSQL_BUILD_PREFIX"
fi
......
......@@ -70,6 +70,11 @@
/* Size of buffer for dump's select query */
#define QUERY_LENGTH 1536
/* ignore table flags */
#define IGNORE_NONE 0x00 /* no ignore */
#define IGNORE_DATA 0x01 /* don't dump data for this table */
#define IGNORE_INSERT_DELAYED 0x02 /* table doesn't support INSERT DELAYED */
static char *add_load_option(char *ptr, const char *object,
const char *statement);
static ulong find_set(TYPELIB *lib, const char *x, uint length,
......@@ -209,9 +214,7 @@ static struct my_option my_long_options[] =
{"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &default_charset,
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED; "
"currently ignored because of http://bugs.mysql.com/bug.php?id=7815 "
"but will be re-enabled later",
{"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED; ",
(gptr*) &opt_delayed, (gptr*) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
{"delete-master-logs", OPT_DELETE_MASTER_LOGS,
......@@ -411,7 +414,7 @@ static int init_dumping(char *);
static int dump_databases(char **);
static int dump_all_databases();
static char *quote_name(const char *name, char *buff, my_bool force);
static const char *check_if_ignore_table(const char *table_name);
char check_if_ignore_table(const char *table_name, char *table_type);
static char *primary_key_fields(const char *table_name);
static my_bool get_view_structure(char *table, char* db);
static my_bool dump_all_views_in_db(char *database);
......@@ -720,25 +723,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
}
break;
}
#ifndef REMOVE_THIS_CODE_WHEN_FIX_BUG_7815
case (int) OPT_DELAYED:
/*
Because of http://bugs.mysql.com/bug.php?id=7815, we disable
--delayed-insert; when the bug gets fixed by checking the storage engine
(using the table definition cache) before printing INSERT DELAYED, we
can correct the option's description and re-enable it again (scheduled
for later 5.0 or 5.1 versions).
It's ok to do the if() below as get_one_option is called after
opt_delayed is set.
*/
if (opt_delayed)
{
fprintf(stderr, "Warning: ignoring --delayed-insert (as explained "
"in the output of 'mysqldump --help').\n");
opt_delayed= 0;
}
break;
#endif
}
return 0;
}
......@@ -1280,19 +1264,27 @@ static uint dump_routines_for_db (char *db)
}
/*
getTableStructure -- retrievs database structure, prints out corresponding
CREATE statement and fills out insert_pat.
get_table_structure -- retrievs database structure, prints out corresponding
CREATE statement and fills out insert_pat if the table is the type we will
be dumping.
ARGS
table - table name
db - db name
table_type - table type ie "InnoDB"
ignore_flag - what we must particularly ignore - see IGNORE_ defines above
RETURN
number of fields in table, 0 if error
*/
static uint get_table_structure(char *table, char *db)
static uint get_table_structure(char *table, char *db, char *table_type,
char *ignore_flag)
{
MYSQL_RES *tableRes;
MYSQL_ROW row;
my_bool init=0;
uint numFields;
uint num_fields;
char *result_table, *opt_quoted_table;
const char *insert_option;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
......@@ -1300,18 +1292,30 @@ static uint get_table_structure(char *table, char *db)
char query_buff[512];
FILE *sql_file = md_result_file;
int len;
DBUG_ENTER("get_table_structure");
DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
if (!insert_pat_inited)
*ignore_flag= check_if_ignore_table(table, table_type);
if (opt_delayed && (*ignore_flag & IGNORE_INSERT_DELAYED))
if (verbose)
fprintf(stderr,
"-- Unable to use delayed inserts for table '%s' because it's of\
type %s\n", table, table_type);
if (!(*ignore_flag & IGNORE_DATA))
{
insert_pat_inited= init_dynamic_string(&insert_pat, "", 1024, 1024);
if (!insert_pat_inited)
insert_pat_inited= init_dynamic_string(&insert_pat, "", 1024, 1024);
else
dynstr_set(&insert_pat, "");
}
else
dynstr_set(&insert_pat, "");
insert_option= ((opt_delayed && opt_ignore) ? " DELAYED IGNORE " :
opt_delayed ? " DELAYED " :
insert_option= ((opt_delayed && opt_ignore &&
!(*ignore_flag & IGNORE_INSERT_DELAYED)) ?
" DELAYED IGNORE " :
opt_delayed && !(*ignore_flag & IGNORE_INSERT_DELAYED) ? " DELAYED " :
opt_ignore ? " IGNORE " : "");
if (verbose)
......@@ -1321,7 +1325,8 @@ static uint get_table_structure(char *table, char *db)
"SET OPTION SQL_QUOTE_SHOW_CREATE=%d",
(opt_quoted || opt_keywords));
if (!create_options)
strmov(query_buff+len, "/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') */");
strmov(query_buff+len,
"/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') */");
result_table= quote_name(table, table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
......@@ -1442,34 +1447,42 @@ static uint get_table_structure(char *table, char *db)
DBUG_RETURN(0);
}
dynstr_append_mem(&insert_pat, "INSERT ", 7);
dynstr_append(&insert_pat, insert_option);
dynstr_append_mem(&insert_pat, "INTO ", 5);
dynstr_append(&insert_pat, opt_quoted_table);
if (opt_complete_insert)
{
dynstr_append_mem(&insert_pat, " (", 2);
}
else
/*
if *ignore_flag & IGNORE_DATA is true, then we don't build up insert statements
for the table's data. Note: in subsequent lines of code, this test will
have to be performed each time we are appending to insert_pat.
*/
if (!(*ignore_flag & IGNORE_DATA))
{
dynstr_append_mem(&insert_pat, " VALUES ", 8);
if (!extended_insert)
dynstr_append_mem(&insert_pat, "(", 1);
dynstr_append_mem(&insert_pat, "INSERT ", 7);
dynstr_append(&insert_pat, insert_option);
dynstr_append_mem(&insert_pat, "INTO ", 5);
dynstr_append(&insert_pat, opt_quoted_table);
if (opt_complete_insert)
{
dynstr_append_mem(&insert_pat, " (", 2);
}
else
{
dynstr_append_mem(&insert_pat, " VALUES ", 8);
if (!extended_insert)
dynstr_append_mem(&insert_pat, "(", 1);
}
}
while ((row=mysql_fetch_row(tableRes)))
{
if (init)
{
if (opt_complete_insert)
if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
dynstr_append_mem(&insert_pat, ", ", 2);
}
init=1;
if (opt_complete_insert)
if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
dynstr_append(&insert_pat,
quote_name(row[SHOW_FIELDNAME], name_buff, 0));
}
numFields = (uint) mysql_num_rows(tableRes);
num_fields= (uint) mysql_num_rows(tableRes);
mysql_free_result(tableRes);
}
else
......@@ -1515,19 +1528,20 @@ static uint get_table_structure(char *table, char *db)
check_io(sql_file);
}
dynstr_append_mem(&insert_pat, "INSERT ", 7);
dynstr_append(&insert_pat, insert_option);
dynstr_append_mem(&insert_pat, "INTO ", 5);
dynstr_append(&insert_pat, result_table);
if (opt_complete_insert)
if (!(*ignore_flag & IGNORE_DATA))
{
dynstr_append_mem(&insert_pat, " (", 2);
}
else
{
dynstr_append_mem(&insert_pat, " VALUES ", 8);
if (!extended_insert)
dynstr_append_mem(&insert_pat, "(", 1);
dynstr_append_mem(&insert_pat, "INSERT ", 7);
dynstr_append(&insert_pat, insert_option);
dynstr_append_mem(&insert_pat, "INTO ", 5);
dynstr_append(&insert_pat, result_table);
if (opt_complete_insert)
dynstr_append_mem(&insert_pat, " (", 2);
else
{
dynstr_append_mem(&insert_pat, " VALUES ", 8);
if (!extended_insert)
dynstr_append_mem(&insert_pat, "(", 1);
}
}
while ((row=mysql_fetch_row(tableRes)))
......@@ -1540,11 +1554,11 @@ static uint get_table_structure(char *table, char *db)
fputs(",\n",sql_file);
check_io(sql_file);
}
if (opt_complete_insert)
if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
dynstr_append_mem(&insert_pat, ", ", 2);
}
init=1;
if (opt_complete_insert)
if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
dynstr_append(&insert_pat,
quote_name(row[SHOW_FIELDNAME], name_buff, 0));
if (!tFlag)
......@@ -1575,7 +1589,7 @@ static uint get_table_structure(char *table, char *db)
check_io(sql_file);
}
}
numFields = (uint) mysql_num_rows(tableRes);
num_fields = (uint) mysql_num_rows(tableRes);
mysql_free_result(tableRes);
if (!tFlag)
{
......@@ -1627,7 +1641,7 @@ static uint get_table_structure(char *table, char *db)
print_xml_row(sql_file, "key", tableRes, &row);
continue;
}
if (atoi(row[3]) == 1)
{
if (keynr++)
......@@ -1684,9 +1698,7 @@ static uint get_table_structure(char *table, char *db)
else
{
if (opt_xml)
{
print_xml_row(sql_file, "options", tableRes, &row);
}
else
{
fputs("/*!",sql_file);
......@@ -1707,7 +1719,7 @@ static uint get_table_structure(char *table, char *db)
check_io(sql_file);
}
}
if (opt_complete_insert)
if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
{
dynstr_append_mem(&insert_pat, ") VALUES ", 9);
if (!extended_insert)
......@@ -1719,7 +1731,7 @@ static uint get_table_structure(char *table, char *db)
write_footer(sql_file);
my_fclose(sql_file, MYF(MY_WME));
}
DBUG_RETURN(numFields);
DBUG_RETURN(num_fields);
} /* get_table_structure */
......@@ -1844,20 +1856,40 @@ static char *alloc_query_str(ulong size)
/*
** dump_table saves database contents as a series of INSERT statements.
SYNOPSIS
dump_table()
dump_table saves database contents as a series of INSERT statements.
ARGS
table - table name
db - db name
RETURNS
void
*/
static void dump_table(uint numFields, char *table)
static void dump_table(char *table, char *db)
{
char ignore_flag;
char query_buf[QUERY_LENGTH], *end, buff[256],table_buff[NAME_LEN+3];
char table_type[NAME_LEN];
char *result_table, table_buff2[NAME_LEN*2+3], *opt_quoted_table;
char *query= query_buf;
int error= 0;
ulong rownr, row_break, total_length, init_length;
uint num_fields;
MYSQL_RES *res;
MYSQL_FIELD *field;
MYSQL_ROW row;
ulong rownr, row_break, total_length, init_length;
const char *table_type;
int error= 0;
DBUG_ENTER("dump_table");
/*
Make sure you get the create table info before the following check for
--no-data flag below. Otherwise, the create table info won't be printed.
*/
num_fields= get_table_structure(table, db, (char *)&table_type, &ignore_flag);
/* Check --no-data flag */
if (dFlag)
......@@ -1866,31 +1898,35 @@ static void dump_table(uint numFields, char *table)
fprintf(stderr,
"-- Skipping dump data for table '%s', --no-data was used\n",
table);
return;
DBUG_VOID_RETURN;
}
DBUG_PRINT("info", ("ignore_flag %x num_fields %d", ignore_flag, num_fields));
/*
If the table type is a merge table or any type that has to be
_completely_ ignored and no data dumped
*/
if (ignore_flag & IGNORE_DATA)
{
if (verbose)
fprintf(stderr,
"-- Skipping data for table '%s' because it's of type %s\n",
table, table_type);
DBUG_VOID_RETURN;
}
/* Check that there are any fields in the table */
if (numFields == 0)
if (num_fields == 0)
{
if (verbose)
fprintf(stderr,
"-- Skipping dump data for table '%s', it has no fields\n",
table);
return;
DBUG_VOID_RETURN;
}
result_table= quote_name(table,table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
/* Check table type */
if ((table_type= check_if_ignore_table(table)))
{
if (verbose)
fprintf(stderr,
"-- Skipping data for table '%s' because it's of type %s\n",
table, table_type);
return;
}
if (verbose)
fprintf(stderr, "-- Sending SELECT query...\n");
......@@ -1934,7 +1970,7 @@ static void dump_table(uint numFields, char *table)
if (mysql_real_query(sock, query, (uint) (end - query)))
{
DB_error(sock, "when executing 'SELECT INTO OUTFILE'");
return;
DBUG_VOID_RETURN;
}
}
else
......@@ -1989,7 +2025,7 @@ static void dump_table(uint numFields, char *table)
DB_error(sock, "when retrieving data from server");
if (verbose)
fprintf(stderr, "-- Retrieving rows...\n");
if (mysql_num_fields(res) != numFields)
if (mysql_num_fields(res) != num_fields)
{
fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n",
my_progname, result_table);
......@@ -2052,7 +2088,7 @@ static void dump_table(uint numFields, char *table)
error= EX_CONSCHECK;
goto err;
}
/*
63 is my_charset_bin. If charsetnr is not 63,
we have not a BLOB but a TEXT column.
......@@ -2287,14 +2323,14 @@ static void dump_table(uint numFields, char *table)
mysql_free_result(res);
if (query != query_buf)
my_free(query, MYF(MY_ALLOW_ZERO_PTR));
}
return;
}
DBUG_VOID_RETURN;
err:
if (query != query_buf)
my_free(query, MYF(MY_ALLOW_ZERO_PTR));
safe_exit(error);
return;
DBUG_VOID_RETURN;
} /* dump_table */
......@@ -2495,8 +2531,7 @@ static int dump_all_tables_in_db(char *database)
char *end= strmov(afterdot, table);
if (include_table(hash_key, end - hash_key))
{
numrows = get_table_structure(table, database);
dump_table(numrows,table);
dump_table(table,database);
my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
order_by= 0;
if (opt_dump_triggers && ! opt_xml &&
......@@ -2630,7 +2665,7 @@ static int get_actual_table_name(const char *old_table_name,
static int dump_selected_tables(char *db, char **table_names, int tables)
{
uint numrows, i;
uint i;
char table_buff[NAME_LEN*+3];
char new_table_name[NAME_LEN];
DYNAMIC_STRING lock_tables_query;
......@@ -2699,8 +2734,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
{
table_name= hash_element(&dump_tables, i);
DBUG_PRINT("info",("Dumping table %s", table_name));
numrows= get_table_structure(table_name, db);
dump_table(numrows, table_name);
dump_table(table_name,db);
if (opt_dump_triggers &&
mysql_get_server_version(sock) >= 50009)
dump_triggers_for_table(table_name, db);
......@@ -2899,28 +2933,37 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
/*
Check if we the table is one of the table types that should be ignored:
MRG_ISAM, MRG_MYISAM
SYNOPSIS
Check if we the table is one of the table types that should be ignored:
MRG_ISAM, MRG_MYISAM, if opt_delayed, if that table supports delayed inserts.
If the table should be altogether ignored, it returns a TRUE, FALSE if it
should not be ignored. If the user has selected to use INSERT DELAYED, it
sets the value of the bool pointer supports_delayed_inserts to 0 if not
supported, 1 if it is supported.
ARGS
check_if_ignore_table()
table_name Table name to check
table_type Type of table
GLOBAL VARIABLES
sock MySQL socket
verbose Write warning messages
RETURN
0 Table should be backuped
# Type of table (that should be skipped)
char (bit value) See IGNORE_ values at top
*/
static const char *check_if_ignore_table(const char *table_name)
char check_if_ignore_table(const char *table_name, char *table_type)
{
char result= IGNORE_NONE;
char buff[FN_REFLEN+80], show_name_buff[FN_REFLEN];
MYSQL_RES *res;
MYSQL_ROW row;
const char *result= 0;
DBUG_ENTER("check_if_ignore_table");
/* Check memory for quote_for_like() */
DBUG_ASSERT(2*sizeof(table_name) < sizeof(show_name_buff));
......@@ -2934,7 +2977,7 @@ static const char *check_if_ignore_table(const char *table_name)
fprintf(stderr,
"-- Warning: Couldn't get status information for table %s (%s)\n",
table_name,mysql_error(sock));
return 0; /* assume table is ok */
DBUG_RETURN(result); /* assume table is ok */
}
}
if (!(row= mysql_fetch_row(res)))
......@@ -2943,18 +2986,38 @@ static const char *check_if_ignore_table(const char *table_name)
"Error: Couldn't read status information for table %s (%s)\n",
table_name, mysql_error(sock));
mysql_free_result(res);
return 0; /* assume table is ok */
DBUG_RETURN(result); /* assume table is ok */
}
if (!(row[1]))
result= "VIEW";
strmake(table_type,"VIEW", NAME_LEN-1);
else
{
if (strcmp(row[1], (result= "MRG_MyISAM")) &&
strcmp(row[1], (result= "MRG_ISAM")))
result= 0;
/*
If the table type matches any of these, we do support delayed inserts.
Note: we do not want to skip dumping this table if if is not one of
these types, but we do want to use delayed inserts in the dump if
the table type is _NOT_ one of these types
*/
strmake(table_type, row[1], NAME_LEN-1);
if (opt_delayed)
{
if (strcmp(table_type,"MyISAM") &&
strcmp(table_type,"ISAM") &&
strcmp(table_type,"ARCHIVE") &&
strcmp(table_type,"HEAP") &&
strcmp(table_type,"MEMORY"))
result= IGNORE_INSERT_DELAYED;
}
/*
If these two types, we do want to skip dumping the table
*/
if (!dFlag &&
(!strcmp(table_type,"MRG_MyISAM") || !strcmp(table_type,"MRG_ISAM")))
result= IGNORE_DATA;
}
mysql_free_result(res);
return result;
DBUG_RETURN(result);
}
/*
......
......@@ -2137,7 +2137,8 @@ sub mysqld_start ($$$$) {
{
if ( $pid= mtr_spawn($exe, $args, "",
$master->[$idx]->{'path_myerr'},
$master->[$idx]->{'path_myerr'}, "") )
$master->[$idx]->{'path_myerr'}, "",
{ append_log_file => 1 }) )
{
return sleep_until_file_created($master->[$idx]->{'path_mypid'},
$master->[$idx]->{'start_timeout'}, $pid);
......@@ -2148,7 +2149,8 @@ sub mysqld_start ($$$$) {
{
if ( $pid= mtr_spawn($exe, $args, "",
$slave->[$idx]->{'path_myerr'},
$slave->[$idx]->{'path_myerr'}, "") )
$slave->[$idx]->{'path_myerr'}, "",
{ append_log_file => 1 }) )
{
return sleep_until_file_created($slave->[$idx]->{'path_mypid'},
$master->[$idx]->{'start_timeout'}, $pid);
......
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
drop table if exists t2;
Warnings:
Note 1051 Unknown table 't2'
drop table if exists t3;
Warnings:
Note 1051 Unknown table 't3'
drop table if exists t4;
Warnings:
Note 1051 Unknown table 't4'
drop table if exists t5;
Warnings:
Note 1051 Unknown table 't5'
drop table if exists t6;
Warnings:
Note 1051 Unknown table 't6'
create table t1 (id int(8), name varchar(32));
create table t2 (id int(8), name varchar(32)) ENGINE="MyISAM";
create table t3 (id int(8), name varchar(32)) ENGINE="MEMORY";
create table t4 (id int(8), name varchar(32)) ENGINE="HEAP";
create table t5 (id int(8), name varchar(32)) ENGINE="ARCHIVE";
create table t6 (id int(8), name varchar(32)) ENGINE="InnoDB";
insert into t1 values (1, 'first value');
insert into t1 values (2, 'first value');
insert into t1 values (3, 'first value');
insert into t1 values (4, 'first value');
insert into t1 values (5, 'first value');
insert into t2 values (1, 'first value');
insert into t2 values (2, 'first value');
insert into t2 values (3, 'first value');
insert into t2 values (4, 'first value');
insert into t2 values (5, 'first value');
insert into t3 values (1, 'first value');
insert into t3 values (2, 'first value');
insert into t3 values (3, 'first value');
insert into t3 values (4, 'first value');
insert into t3 values (5, 'first value');
insert into t4 values (1, 'first value');
insert into t4 values (2, 'first value');
insert into t4 values (3, 'first value');
insert into t4 values (4, 'first value');
insert into t4 values (5, 'first value');
insert into t5 values (1, 'first value');
insert into t5 values (2, 'first value');
insert into t5 values (3, 'first value');
insert into t5 values (4, 'first value');
insert into t5 values (5, 'first value');
insert into t6 values (1, 'first value');
insert into t6 values (2, 'first value');
insert into t6 values (3, 'first value');
insert into t6 values (4, 'first value');
insert into t6 values (5, 'first value');
select * from t1;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t2;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t3;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t4;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t5;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t6;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
/*!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 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`;
CREATE TABLE `t3` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`;
CREATE TABLE `t4` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`;
CREATE TABLE `t5` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`;
CREATE TABLE `t6` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t6` ENABLE KEYS */;
/*!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 */;
/*!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 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`;
CREATE TABLE `t3` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`;
CREATE TABLE `t4` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`;
CREATE TABLE `t5` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`;
CREATE TABLE `t6` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t6` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;
drop table t6;
......@@ -614,9 +614,7 @@ CREATE TABLE `t1` (
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
UNLOCK TABLES;
INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......
......@@ -2262,3 +2262,29 @@ WEEKDAY(date)
1
DROP TABLE t1;
DROP VIEW v1, v2, v3;
CREATE TABLE t1 ( a int, b int );
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
CREATE VIEW v1 AS SELECT a,b FROM t1;
SELECT t1.a FROM t1 GROUP BY t1.a HAVING a > 1;
a
2
3
SELECT v1.a FROM v1 GROUP BY v1.a HAVING a > 1;
a
2
3
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 ( a int, b int );
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
CREATE VIEW v1 AS SELECT a,b FROM t1;
SELECT t1.a FROM t1 GROUP BY t1.a HAVING t1.a > 1;
a
2
3
SELECT v1.a FROM v1 GROUP BY v1.a HAVING v1.a > 1;
a
2
3
DROP VIEW v1;
DROP TABLE t1;
# Embedded server doesn't support external clients
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_archive.inc
--disable-warnings
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop table if exists t4;
drop table if exists t5;
drop table if exists t6;
--enable-warnings
create table t1 (id int(8), name varchar(32));
create table t2 (id int(8), name varchar(32)) ENGINE="MyISAM";
create table t3 (id int(8), name varchar(32)) ENGINE="MEMORY";
create table t4 (id int(8), name varchar(32)) ENGINE="HEAP";
create table t5 (id int(8), name varchar(32)) ENGINE="ARCHIVE";
create table t6 (id int(8), name varchar(32)) ENGINE="InnoDB";
insert into t1 values (1, 'first value');
insert into t1 values (2, 'first value');
insert into t1 values (3, 'first value');
insert into t1 values (4, 'first value');
insert into t1 values (5, 'first value');
insert into t2 values (1, 'first value');
insert into t2 values (2, 'first value');
insert into t2 values (3, 'first value');
insert into t2 values (4, 'first value');
insert into t2 values (5, 'first value');
insert into t3 values (1, 'first value');
insert into t3 values (2, 'first value');
insert into t3 values (3, 'first value');
insert into t3 values (4, 'first value');
insert into t3 values (5, 'first value');
insert into t4 values (1, 'first value');
insert into t4 values (2, 'first value');
insert into t4 values (3, 'first value');
insert into t4 values (4, 'first value');
insert into t4 values (5, 'first value');
insert into t5 values (1, 'first value');
insert into t5 values (2, 'first value');
insert into t5 values (3, 'first value');
insert into t5 values (4, 'first value');
insert into t5 values (5, 'first value');
insert into t6 values (1, 'first value');
insert into t6 values (2, 'first value');
insert into t6 values (3, 'first value');
insert into t6 values (4, 'first value');
insert into t6 values (5, 'first value');
select * from t1;
select * from t2;
select * from t3;
select * from t4;
select * from t5;
select * from t6;
--exec $MYSQL_DUMP --skip-comments --delayed-insert --insert-ignore --databases test
--exec $MYSQL_DUMP --skip-comments --delayed-insert --databases test
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;
drop table t6;
......@@ -2139,3 +2139,29 @@ SELECT * FROM v3;
DROP TABLE t1;
DROP VIEW v1, v2, v3;
#
# Bug #13411: crash when using non-qualified view column in HAVING clause
#
CREATE TABLE t1 ( a int, b int );
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
CREATE VIEW v1 AS SELECT a,b FROM t1;
SELECT t1.a FROM t1 GROUP BY t1.a HAVING a > 1;
SELECT v1.a FROM v1 GROUP BY v1.a HAVING a > 1;
DROP VIEW v1;
DROP TABLE t1;
#
# Bug #13410: failed name resolution for qualified view column in HAVING
#
CREATE TABLE t1 ( a int, b int );
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
CREATE VIEW v1 AS SELECT a,b FROM t1;
SELECT t1.a FROM t1 GROUP BY t1.a HAVING t1.a > 1;
SELECT v1.a FROM v1 GROUP BY v1.a HAVING v1.a > 1;
DROP VIEW v1;
DROP TABLE t1;
......@@ -1687,7 +1687,7 @@ bool Item_field::eq(const Item *item, bool binary_cmp) const
return 0;
Item_field *item_field= (Item_field*) item;
if (item_field->field)
if (item_field->field && field)
return item_field->field == field;
/*
We may come here when we are trying to find a function in a GROUP BY
......@@ -1701,10 +1701,10 @@ bool Item_field::eq(const Item *item, bool binary_cmp) const
*/
return (!my_strcasecmp(system_charset_info, item_field->name,
field_name) &&
(!item_field->table_name ||
(!item_field->table_name || !table_name ||
(!my_strcasecmp(table_alias_charset, item_field->table_name,
table_name) &&
(!item_field->db_name ||
(!item_field->db_name || !db_name ||
(item_field->db_name && !strcmp(item_field->db_name,
db_name))))));
}
......@@ -2983,7 +2983,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
for (ORDER *cur_group= group_list ; cur_group ; cur_group= cur_group->next)
{
if ((*(cur_group->item))->type() == Item::FIELD_ITEM)
if ((*(cur_group->item))->real_item()->type() == Item::FIELD_ITEM)
{
cur_field= (Item_field*) *cur_group->item;
cur_match_degree= 0;
......
......@@ -3459,7 +3459,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
}
}
}
else if (!table_name && (item->eq(find,0) ||
else if (!table_name && (find->eq(item,0) ||
find->name && item->name &&
!my_strcasecmp(system_charset_info,
item->name,find->name)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment