Commit f3c2cc13 authored by unknown's avatar unknown

Merge msvensson.mysql.internal:mysql/mysql-5.1-maint

into  shellback.(none):/home/msvensson/mysql/mysql-5.1-maint

parents cf6b5738 549c922b
......@@ -8,6 +8,12 @@ LIMIT=10000
VERSION="5.1"
BKROOT=`bk root`
if [ -x /usr/sbin/sendmail ]; then
SENDMAIL=/usr/sbin/sendmail
else
SENDMAIL=sendmail
fi
if [ "$REAL_EMAIL" = "" ]
then
echo "Warning: you must set REAL_EMAIL in your profile"
......@@ -61,7 +67,7 @@ EOF
bk cset -r+ -d
) > $BKROOT/BitKeeper/tmp/dev_public.txt
bk sendmail -t < $BKROOT/BitKeeper/tmp/dev_public.txt
$SENDMAIL -t < $BKROOT/BitKeeper/tmp/dev_public.txt
#++
# commits@ mail
......@@ -87,7 +93,7 @@ EOF
bk cset -r+ -d
) | bk sed -e ${LIMIT}q > $BKROOT/BitKeeper/tmp/commits.txt
bk sendmail -t < $BKROOT/BitKeeper/tmp/commits.txt
$SENDMAIL -t < $BKROOT/BitKeeper/tmp/commits.txt
#++
# docs-commit@ mail
......@@ -108,7 +114,7 @@ EOF
bk changes -v -r+
bk cset -r+ -d
) > $BKROOT/BitKeeper/tmp/docs.txt
bk sendmail -t < $BKROOT/BitKeeper/tmp/docs.txt
$SENDMAIL -t < $BKROOT/BitKeeper/tmp/docs.txt
fi
else
......
......@@ -2301,10 +2301,8 @@ print_table_data(MYSQL_RES *result)
MYSQL_ROW cur;
MYSQL_FIELD *field;
bool *num_flag;
bool *not_null_flag;
num_flag=(bool*) my_alloca(sizeof(bool)*mysql_num_fields(result));
not_null_flag=(bool*) my_alloca(sizeof(bool)*mysql_num_fields(result));
if (info_flag)
{
print_field_types(result);
......@@ -2343,7 +2341,6 @@ print_table_data(MYSQL_RES *result)
MAX_COLUMN_LENGTH),
field->name);
num_flag[off]= IS_NUM(field->type);
not_null_flag[off]= IS_NOT_NULL(field->flags);
}
(void) tee_fputs("\n", PAGER);
tee_puts((char*) separator.ptr(), PAGER);
......@@ -2364,7 +2361,7 @@ print_table_data(MYSQL_RES *result)
uint visible_length;
uint extra_padding;
if (! not_null_flag[off] && (cur[off] == NULL))
if (cur[off] == NULL)
{
buffer= "NULL";
data_length= 4;
......@@ -2404,7 +2401,6 @@ print_table_data(MYSQL_RES *result)
}
tee_puts((char*) separator.ptr(), PAGER);
my_afree((gptr) num_flag);
my_afree((gptr) not_null_flag);
}
......
......@@ -200,7 +200,7 @@ static int create_defaults_file(const char *path, const char *our_defaults_path)
}
buffer_end= strnmov(buffer, "\n[client]", sizeof(buffer));
if (opt_password)
buffer_end= strxnmov(buffer, sizeof(buffer),
buffer_end= strxnmov(buffer_end, sizeof(buffer),
"\npassword=", opt_password, NullS);
error= my_write(defaults_file, buffer, (int) (buffer_end - buffer),
MYF(MY_WME | MY_FNABP));
......
......@@ -86,7 +86,7 @@ static char *alloc_query_str(ulong size);
static char *field_escape(char *to,const char *from,uint length);
static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
quick= 1, extended_insert= 1,
lock_tables=1,ignore_errors=0,flush_logs=0,
lock_tables=1,ignore_errors=0,flush_logs=0,flush_privileges=0,
opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0,
opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0,
opt_alldbs=0,opt_create_db=0,opt_lock_all_tables=0,
......@@ -266,6 +266,12 @@ static struct my_option my_long_options[] =
"--lock-all-tables or --master-data with --flush-logs",
(gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
{"flush-privileges", OPT_ESC, "Emit a FLUSH PRIVILEGES statement "
"after dumping the mysql database. This option should be used any "
"time the dump contains the mysql database and any other database "
"that depends on the data in the mysql database for proper restore. ",
(gptr*) &flush_privileges, (gptr*) &flush_privileges, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
{"force", 'f', "Continue even if we get an sql-error.",
(gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
......@@ -3037,6 +3043,7 @@ static int dump_all_tables_in_db(char *database)
char hash_key[2*NAME_LEN+2]; /* "db.tablename" */
char *afterdot;
int using_mysql_db= my_strcasecmp(&my_charset_latin1, database, "mysql");
afterdot= strmov(hash_key, database);
*afterdot++= '.';
......@@ -3099,6 +3106,11 @@ static int dump_all_tables_in_db(char *database)
}
if (lock_tables)
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
if (flush_privileges && using_mysql_db == 0)
{
fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n");
fprintf(md_result_file,"\n/*! FLUSH PRIVILEGES */;\n");
}
return 0;
} /* dump_all_tables_in_db */
......
......@@ -695,6 +695,16 @@ CREATE TABLE t2 (z int, y int);
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
DROP TABLE IF EXISTS t1,t2,t3;
CREATE DATABASE bug21774_1;
CREATE DATABASE bug21774_2;
CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
use bug21774_1;
INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
DROP DATABASE bug21774_1;
DROP DATABASE bug21774_2;
CREATE DATABASE meow;
CREATE TABLE table_target ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
CREATE TABLE table_target2 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
......
......@@ -85,6 +85,12 @@ c_cp932
| NULL | NULL | Τη γλώσσα |
| NULL | NULL | ᛖᚴ ᚷᛖᛏ |
+------+------+---------------------------+
i j k
NULL 1 NULL
Field Type Null Key Default Extra
i int(11) YES NULL
j int(11) NO
k int(11) YES NULL
+------+---+------+
| i | j | k |
+------+---+------+
......@@ -97,6 +103,10 @@ c_cp932
| j | int(11) | NO | | | |
| k | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
i s1
1 x
2 NULL
3
+------+------+
| i | s1 |
+------+------+
......@@ -104,6 +114,13 @@ c_cp932
| 2 | NULL |
| 3 | |
+------+------+
unhex('zz')
NULL
+-------------+
| unhex('zz') |
+-------------+
| NULL |
+-------------+
create table t1(a int, b varchar(255), c int);
Field Type Null Key Default Extra
a int(11) YES NULL
......
......@@ -2923,14 +2923,32 @@ drop user mysqltest_1@localhost;
create database mysqldump_myDB;
use mysqldump_myDB;
create user myDB_User;
grant create view, select on mysqldump_myDB.* to myDB_User@localhost;
grant create, create view, select, insert on mysqldump_myDB.* to myDB_User@localhost;
create table t1 (c1 int);
insert into t1 values (3);
use mysqldump_myDB;
create table u1 (f1 int);
insert into u1 values (4);
create view v1 (c1) as select * from t1;
use mysqldump_myDB;
drop view v1;
drop table t1;
drop table u1;
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
drop user myDB_User;
drop database mysqldump_myDB;
flush privileges;
use mysqldump_myDB;
select * from mysqldump_myDB.v1;
c1
3
select * from mysqldump_myDB.u1;
f1
4
use mysqldump_myDB;
drop view v1;
drop table t1;
drop table u1;
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
drop user myDB_User;
drop database mysqldump_myDB;
......
......@@ -248,6 +248,24 @@ CREATE TABLE t3 (a int, b int);
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
DROP TABLE IF EXISTS t1,t2,t3;
#
# Bug #21774: Column count doesn't match value count at row x
#
CREATE DATABASE bug21774_1;
CREATE DATABASE bug21774_2;
CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
use bug21774_1;
INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
DROP DATABASE bug21774_1;
DROP DATABASE bug21774_2;
#
# Bug #20989: View '(null).(null)' references invalid table(s)... on
# SQL SECURITY INVOKER
......
......@@ -70,13 +70,21 @@ drop table t1;
#
# "DESCRIBE" commands may return strange NULLness flags.
#
--exec $MYSQL --default-character-set utf8 test -e "create table t1 (i int, j int not null, k int); insert into t1 values (null, 1, null); select * from t1; describe t1; drop table t1;"
--exec $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int not null, k int); insert into t1 values (null, 1, null); select * from t1; describe t1; drop table t1;"
#
# Bug#19564: mysql displays NULL instead of space
#
--exec $MYSQL test -e "create table b19564 (i int, s1 char(1)); insert into b19564 values (1, 'x'); insert into b19564 values (2, NULL); insert into b19564 values (3, ' '); select * from b19564 order by i; drop table b19564;"
--exec $MYSQL -t test -e "create table b19564 (i int, s1 char(1)); insert into b19564 values (1, 'x'); insert into b19564 values (2, NULL); insert into b19564 values (3, ' '); select * from b19564 order by i; drop table b19564;"
#
# Bug#21618: NULL shown as empty string in client
#
--exec $MYSQL test -e "select unhex('zz');"
--exec $MYSQL -t test -e "select unhex('zz');"
#
# Bug#19265 describe command does not work from mysql prompt
#
......
......@@ -1325,28 +1325,59 @@ drop user mysqltest_1@localhost;
# Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the
# information_schema database.
#
# Bug #21424 mysqldump failing to export/import views
#
# Do as root
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection root;
create database mysqldump_myDB;
use mysqldump_myDB;
create user myDB_User;
grant create view, select on mysqldump_myDB.* to myDB_User@localhost;
grant create, create view, select, insert on mysqldump_myDB.* to myDB_User@localhost;
create table t1 (c1 int);
insert into t1 values (3);
# Do as a user
connect (user1,localhost,myDB_User,,mysqldump_myDB,$MASTER_MYPORT,$MASTER_MYSOCK);
connection user1;
use mysqldump_myDB;
create table u1 (f1 int);
insert into u1 values (4);
create view v1 (c1) as select * from t1;
# Backup should not fail.
--exec $MYSQL_DUMP --all-databases --add-drop-table > $MYSQLTEST_VARDIR/tmp/bug21527.sql
# Backup should not fail for Bug #21527. Flush priviliges test begins.
--exec $MYSQL_DUMP --skip-comments --add-drop-table --flush-privileges --ignore-table=mysql.general_log --ignore-table=mysql.slow_log --databases mysqldump_myDB mysql > $MYSQLTEST_VARDIR/tmp/bug21527.sql
# Clean up
connection root;
use mysqldump_myDB;
drop view v1;
drop table t1;
drop table u1;
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
drop user myDB_User;
drop database mysqldump_myDB;
flush privileges;
# Bug #21424 continues from here.
# Restore. Flush Privileges test ends.
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21527.sql;
# Do as a user
connection user1;
use mysqldump_myDB;
# Ultimate test for correct data.
select * from mysqldump_myDB.v1;
select * from mysqldump_myDB.u1;
#Final cleanup.
connection root;
use mysqldump_myDB;
drop view v1;
drop table t1;
drop table u1;
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
drop user myDB_User;
drop database mysqldump_myDB;
......
......@@ -5371,7 +5371,20 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
uint tablenr= 0;
DBUG_ENTER("setup_tables");
context->table_list= context->first_name_resolution_table= tables;
/*
Due to the various call paths that lead to setup_tables() it may happen
that context->table_list and context->first_name_resolution_table can be
NULL (this is typically done when creating TABLE_LISTs internally).
TODO:
Investigate all cases when this my happen, initialize the name resolution
context correctly in all those places, and remove the context reset below.
*/
if (!context->table_list || !context->first_name_resolution_table)
{
/* Test whether the context is in a consistent state. */
DBUG_ASSERT(!context->first_name_resolution_table && !context->table_list);
context->table_list= context->first_name_resolution_table= tables;
}
/*
this is used for INSERT ... SELECT.
......
......@@ -395,6 +395,15 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
table= table_list->table;
context= &thd->lex->select_lex.context;
/*
These three asserts test the hypothesis that the resetting of the name
resolution context below is not necessary at all since the list of local
tables for INSERT always consists of one table.
*/
DBUG_ASSERT(!table_list->next_local);
DBUG_ASSERT(!context->table_list->next_local);
DBUG_ASSERT(!context->first_name_resolution_table->next_name_resolution_table);
/* Save the state of the current name resolution context. */
ctx_state.save_state(context, table_list);
......
......@@ -3383,8 +3383,6 @@ mysql_execute_command(THD *thd)
DBUG_ASSERT(first_table == all_tables && first_table != 0);
if ((res= insert_precheck(thd, all_tables)))
break;
/* Skip first table, which is the table we are inserting in */
select_lex->context.table_list= first_table->next_local;
if (!thd->locked_tables &&
!(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
......
......@@ -728,7 +728,7 @@ int ha_archive::create(const char *name, TABLE *table_arg,
goto error;
}
}
if (!azdopen(&archive, dup(create_file), O_WRONLY|O_BINARY))
if (!azdopen(&archive, create_file, O_WRONLY|O_BINARY))
{
error= errno;
goto error2;
......
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