Commit 6adaff23 authored by monty@mysql.com's avatar monty@mysql.com

Review of new pushed code (Indentation fixes and simple optimizations)

Use 'mysqltest' as test database instead of test_$1 or test1,test2 to not accidently delete an important database
Safety fix for mailformed MERGE files
parent ceba1429
...@@ -150,20 +150,20 @@ sub main ...@@ -150,20 +150,20 @@ sub main
#### ####
sub fix_mysql_version sub fix_mysql_version
{ {
chdir("$destdir"); chdir("$destdir");
my $header_file= (-f 'include/mysql_version.h.in')? 'include/mysql_version.h.in' : 'include/mysql_version.h'; my $header_file= (-f 'include/mysql_version.h.in')? 'include/mysql_version.h.in' : 'include/mysql_version.h';
open(MYSQL_VERSION,"<$header_file") or die "Unable to open include/mysql_version.h for read: $!\n";
undef $/;
my $mysql_version= <MYSQL_VERSION>;
close(MYSQL_VERSION);
$mysql_version=~ s/\#define LICENSE[\s\t]+GPL/#define LICENSE Commercial/; open(MYSQL_VERSION,"<$header_file") or die "Unable to open $header_file for read: $!\n";
undef $/;
open(MYSQL_VERSION,">$header_file") or die "Unable to open include/mysql_version.h for write: $!\n"; my $mysql_version= <MYSQL_VERSION>;
print MYSQL_VERSION $mysql_version; close(MYSQL_VERSION);
close(MYSQL_VERSION);
chdir("$cwd"); $mysql_version=~ s/\#define LICENSE[\s\t]+GPL/#define LICENSE Commercial/;
open(MYSQL_VERSION,">$header_file") or die "Unable to open $header_file for write: $!\n";
print MYSQL_VERSION $mysql_version;
close(MYSQL_VERSION);
chdir("$cwd");
} }
#### ####
......
...@@ -151,9 +151,7 @@ typedef uint rf_SetTimer; ...@@ -151,9 +151,7 @@ typedef uint rf_SetTimer;
#endif #endif
/* ERROR is defined in wingdi.h */ /* ERROR is defined in wingdi.h */
#ifdef ERROR
#undef ERROR #undef ERROR
#endif
/* We need to close files to break connections on shutdown */ /* We need to close files to break connections on shutdown */
#ifndef SIGNAL_WITH_VIO_CLOSE #ifndef SIGNAL_WITH_VIO_CLOSE
......
...@@ -34,14 +34,17 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -34,14 +34,17 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
{ {
int save_errno,errpos=0; int save_errno,errpos=0;
uint files=0,i,dir_length,length,key_parts; uint files=0,i,dir_length,length,key_parts;
ulonglong file_offset; ulonglong file_offset=0;
char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end;
MYRG_INFO *m_info=0; MYRG_INFO *m_info=0;
File fd; File fd;
IO_CACHE file; IO_CACHE file;
MI_INFO *isam=0; MI_INFO *isam=0;
uint found_merge_insert_method= 0;
DBUG_ENTER("myrg_open"); DBUG_ENTER("myrg_open");
LINT_INIT(key_parts);
bzero((char*) &file,sizeof(file)); bzero((char*) &file,sizeof(file));
if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT,4), if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT,4),
O_RDONLY | O_SHARE,MYF(0))) < 0) O_RDONLY | O_SHARE,MYF(0))) < 0)
...@@ -69,10 +72,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -69,10 +72,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
continue; /* Skip empty lines */ continue; /* Skip empty lines */
if (buff[0] == '#') if (buff[0] == '#')
{ {
if( !strncmp(buff+1,"INSERT_METHOD=",14)) if (!strncmp(buff+1,"INSERT_METHOD=",14))
{ /* Lookup insert method */ { /* Lookup insert method */
int tmp=find_type(buff+15,&merge_insert_method,2); int tmp=find_type(buff+15,&merge_insert_method,2);
m_info->merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); found_merge_insert_method = (uint) (tmp >= 0 ? tmp : 0);
} }
continue; /* Skip comments */ continue; /* Skip comments */
} }
...@@ -84,8 +87,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -84,8 +87,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
VOID(cleanup_dirname(buff,name_buff)); VOID(cleanup_dirname(buff,name_buff));
} }
if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0))))
goto err; goto err;
if (!m_info) if (!m_info) /* First file */
{ {
key_parts=isam->s->base.key_parts; key_parts=isam->s->base.key_parts;
if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO) + if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO) +
...@@ -97,15 +100,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -97,15 +100,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
{ {
m_info->open_tables=(MYRG_TABLE *) (m_info+1); m_info->open_tables=(MYRG_TABLE *) (m_info+1);
m_info->rec_per_key_part=(ulong *) (m_info->open_tables+files); m_info->rec_per_key_part=(ulong *) (m_info->open_tables+files);
m_info->tables= files;
files= 0;
} }
else
{
m_info->open_tables=0;
m_info->rec_per_key_part=0;
}
m_info->tables=files;
m_info->reclength=isam->s->base.reclength; m_info->reclength=isam->s->base.reclength;
file_offset=files=0;
errpos=3; errpos=3;
} }
m_info->open_tables[files].table= isam; m_info->open_tables[files].table= isam;
...@@ -122,14 +120,16 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -122,14 +120,16 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
m_info->del+= isam->state->del; m_info->del+= isam->state->del;
m_info->data_file_length+= isam->state->data_file_length; m_info->data_file_length+= isam->state->data_file_length;
for (i=0; i < key_parts; i++) for (i=0; i < key_parts; i++)
m_info->rec_per_key_part[i]+=isam->s->state.rec_per_key_part[i] / m_info->tables; m_info->rec_per_key_part[i]+= (isam->s->state.rec_per_key_part[i] /
m_info->tables);
} }
if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO), if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO),
MYF(MY_WME|MY_ZEROFILL)))) MYF(MY_WME | MY_ZEROFILL))))
goto err; goto err;
/* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */ /* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */
m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA); m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA);
m_info->merge_insert_method= found_merge_insert_method;
if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L) if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L)
{ {
......
drop table if exists t1,t2,t3; drop table if exists t1,t2,t3;
drop database if exists test_$1; drop database if exists mysqltest;
create table t1 (b char(0)); create table t1 (b char(0));
insert into t1 values (""),(null); insert into t1 values (""),(null);
select * from t1; select * from t1;
...@@ -58,18 +58,18 @@ select 1ea10.1a20,1e+ 1e+10 from 1ea10; ...@@ -58,18 +58,18 @@ select 1ea10.1a20,1e+ 1e+10 from 1ea10;
drop table 1ea10; drop table 1ea10;
create table t1 (t1.index int); create table t1 (t1.index int);
drop table t1; drop table t1;
drop database if exists test_$1; drop database if exists mysqltest;
Warnings: Warnings:
Note 1008 Can't drop database 'test_$1'; database doesn't exist Note 1008 Can't drop database 'mysqltest'; database doesn't exist
create database test_$1; create database mysqltest;
create table test_$1.$test1 (a$1 int, $b int, c$ int); create table mysqltest.$test1 (a$1 int, $b int, c$ int);
insert into test_$1.$test1 values (1,2,3); insert into mysqltest.$test1 values (1,2,3);
select a$1, $b, c$ from test_$1.$test1; select a$1, $b, c$ from mysqltest.$test1;
a$1 $b c$ a$1 $b c$
1 2 3 1 2 3
create table test_$1.test2$ (a int); create table mysqltest.test2$ (a int);
drop table test_$1.test2$; drop table mysqltest.test2$;
drop database test_$1; drop database mysqltest;
create table `` (a int); create table `` (a int);
ERROR 42000: Incorrect table name '' ERROR 42000: Incorrect table name ''
drop table if exists ``; drop table if exists ``;
...@@ -320,9 +320,9 @@ t3 CREATE TABLE `t3` ( ...@@ -320,9 +320,9 @@ t3 CREATE TABLE `t3` (
select * from t3; select * from t3;
id name id name
drop table t2, t3; drop table t2, t3;
create database test_$1; create database mysqltest;
create table test_$1.t3 like t1; create table mysqltest.t3 like t1;
create temporary table t3 like test_$1.t3; create temporary table t3 like mysqltest.t3;
show create table t3; show create table t3;
Table Create Table Table Create Table
t3 CREATE TEMPORARY TABLE `t3` ( t3 CREATE TEMPORARY TABLE `t3` (
...@@ -339,7 +339,7 @@ t2 CREATE TABLE `t2` ( ...@@ -339,7 +339,7 @@ t2 CREATE TABLE `t2` (
select * from t2; select * from t2;
id name id name
create table t3 like t1; create table t3 like t1;
create table t3 like test_$1.t3; create table t3 like mysqltest.t3;
ERROR 42S01: Table 't3' already exists ERROR 42S01: Table 't3' already exists
create table non_existing_database.t1 like t1; create table non_existing_database.t1 like t1;
Got one of the listed errors Got one of the listed errors
...@@ -351,7 +351,7 @@ create table t3 like `a/a`; ...@@ -351,7 +351,7 @@ create table t3 like `a/a`;
ERROR 42000: Incorrect table name 'a/a' ERROR 42000: Incorrect table name 'a/a'
drop table t1, t2, t3; drop table t1, t2, t3;
drop table t3; drop table t3;
drop database test_$1; drop database mysqltest;
SET SESSION storage_engine="heap"; SET SESSION storage_engine="heap";
SELECT @@storage_engine; SELECT @@storage_engine;
@@storage_engine @@storage_engine
...@@ -488,12 +488,12 @@ Note 1291 Column 'cset' has duplicated value 'b' in SET ...@@ -488,12 +488,12 @@ Note 1291 Column 'cset' has duplicated value 'b' in SET
Note 1291 Column 'cset' has duplicated value 'B' in SET Note 1291 Column 'cset' has duplicated value 'B' in SET
Note 1291 Column 'cset' has duplicated value 'd' in SET Note 1291 Column 'cset' has duplicated value 'd' in SET
drop table t1, t2, t3; drop table t1, t2, t3;
create database test_$1; create database mysqltest;
use test_$1; use mysqltest;
select database(); select database();
database() database()
test_$1 mysqltest
drop database test_$1; drop database mysqltest;
select database(); select database();
database() database()
NULL NULL
......
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
drop database if exists test2; drop database if exists mysqltest;
CREATE TABLE t1 ( CREATE TABLE t1 (
pk1 INT NOT NULL PRIMARY KEY, pk1 INT NOT NULL PRIMARY KEY,
attr1 INT NOT NULL, attr1 INT NOT NULL,
...@@ -1362,8 +1362,8 @@ attr2 INT, ...@@ -1362,8 +1362,8 @@ attr2 INT,
attr3 VARCHAR(10) attr3 VARCHAR(10)
) ENGINE=ndbcluster; ) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413');
create database test2; create database mysqltest;
use test2; use mysqltest;
CREATE TABLE t2 ( CREATE TABLE t2 (
a bigint unsigned NOT NULL PRIMARY KEY, a bigint unsigned NOT NULL PRIMARY KEY,
b int unsigned not null, b int unsigned not null,
...@@ -1381,4 +1381,4 @@ select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a; ...@@ -1381,4 +1381,4 @@ select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a;
b attr1 b attr1
9413 9412 9413 9412
drop table test.t1, t2; drop table test.t1, t2;
drop database test2; drop database mysqltest;
drop table if exists t1; drop table if exists t1;
drop database if exists test2; drop database if exists mysqltest;
set autocommit=0; set autocommit=0;
create table t1 ( create table t1 (
a int not null primary key, a int not null primary key,
...@@ -256,8 +256,8 @@ a b c d ...@@ -256,8 +256,8 @@ a b c d
7 7xb7 777 7xdd7 7 7xb7 777 7xdd7
8 8xb8 888 8xdd8 8 8xb8 888 8xdd8
9 9xb9 999 9xdd9 9 9xb9 999 9xdd9
create database test2; create database mysqltest;
use test2; use mysqltest;
CREATE TABLE t2 ( CREATE TABLE t2 (
a bigint unsigned NOT NULL PRIMARY KEY, a bigint unsigned NOT NULL PRIMARY KEY,
b int unsigned not null, b int unsigned not null,
...@@ -320,3 +320,5 @@ rollback; ...@@ -320,3 +320,5 @@ rollback;
select count(*) from t1; select count(*) from t1;
count(*) count(*)
0 0
drop table t1;
drop database mysqltest;
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
drop database if exists test2; drop database if exists mysqltest;
CREATE TABLE t1 ( CREATE TABLE t1 (
pk1 INT NOT NULL PRIMARY KEY, pk1 INT NOT NULL PRIMARY KEY,
attr1 INT NOT NULL attr1 INT NOT NULL
...@@ -211,8 +211,8 @@ CREATE TABLE t1 ( ...@@ -211,8 +211,8 @@ CREATE TABLE t1 (
pk1 INT NOT NULL PRIMARY KEY, pk1 INT NOT NULL PRIMARY KEY,
attr1 INT NOT NULL attr1 INT NOT NULL
) ENGINE=ndbcluster; ) ENGINE=ndbcluster;
create database test2; create database mysqltest;
use test2; use mysqltest;
CREATE TABLE t2 ( CREATE TABLE t2 (
a bigint unsigned NOT NULL PRIMARY KEY, a bigint unsigned NOT NULL PRIMARY KEY,
b int unsigned not null, b int unsigned not null,
...@@ -254,4 +254,4 @@ select count(*) from t2; ...@@ -254,4 +254,4 @@ select count(*) from t2;
count(*) count(*)
0 0
drop table test.t1, t2; drop table test.t1, t2;
drop database test2; drop database mysqltest;
...@@ -334,12 +334,12 @@ prepare stmt1 from ' deallocate prepare never_prepared ' ; ...@@ -334,12 +334,12 @@ prepare stmt1 from ' deallocate prepare never_prepared ' ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'never_prepared' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'never_prepared' at line 1
prepare stmt4 from ' use test ' ; prepare stmt4 from ' use test ' ;
ERROR HY000: This command is not supported in the prepared statement protocol yet ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt3 from ' create database drop_me '; prepare stmt3 from ' create database mysqltest ';
ERROR HY000: This command is not supported in the prepared statement protocol yet ERROR HY000: This command is not supported in the prepared statement protocol yet
create database drop_me ; create database mysqltest ;
prepare stmt3 from ' drop database drop_me '; prepare stmt3 from ' drop database mysqltest ';
ERROR HY000: This command is not supported in the prepared statement protocol yet ERROR HY000: This command is not supported in the prepared statement protocol yet
drop database drop_me ; drop database mysqltest ;
prepare stmt3 from ' grant all on test.t1 to drop_user@localhost prepare stmt3 from ' grant all on test.t1 to drop_user@localhost
identified by ''looser'' '; identified by ''looser'' ';
ERROR HY000: This command is not supported in the prepared statement protocol yet ERROR HY000: This command is not supported in the prepared statement protocol yet
......
This diff is collapsed.
...@@ -4,12 +4,12 @@ reset master; ...@@ -4,12 +4,12 @@ reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave; start slave;
create database test1; create database mysqltest;
drop database if exists test1; drop database if exists mysqltest;
Warnings: Warnings:
Note 1008 Can't drop database 'test1'; database doesn't exist Note 1008 Can't drop database 'mysqltest'; database doesn't exist
show tables from test1; show tables from mysqltest;
ERROR HY000: Can't read dir of './test1/' (Errcode: X) ERROR HY000: Can't read dir of './mysqltest/' (Errcode: X)
create table t1 (a int); create table t1 (a int);
drop table if exists t1; drop table if exists t1;
Warnings: Warnings:
......
drop table if exists t1,t2; drop table if exists t1,t2;
drop database if exists mysqltest;
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c)); create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4); insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
check table t1 fast; check table t1 fast;
...@@ -362,39 +363,39 @@ t1 HEAP 9 Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL ...@@ -362,39 +363,39 @@ t1 HEAP 9 Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t2 HEAP 9 Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL t2 HEAP 9 Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL
t3 HEAP 9 Fixed 0 9 # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL t3 HEAP 9 Fixed 0 9 # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL
drop table t1, t2, t3; drop table t1, t2, t3;
create database test_$1; create database mysqltest;
show create database test_$1; show create database mysqltest;
Database Create Database Database Create Database
test_$1 CREATE DATABASE `test_$1` /*!40100 DEFAULT CHARACTER SET latin1 */ mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
create table test_$1.t1(a int); create table mysqltest.t1(a int);
insert into test_$1.t1 values(1); insert into mysqltest.t1 values(1);
grant select on `test_$1`.* to mysqltest_1@localhost; grant select on `mysqltest`.* to mysqltest_1@localhost;
grant usage on `test_$1`.* to mysqltest_2@localhost; grant usage on `mysqltest`.* to mysqltest_2@localhost;
grant drop on `test_$1`.* to mysqltest_3@localhost; grant drop on `mysqltest`.* to mysqltest_3@localhost;
select * from t1; select * from t1;
a a
1 1
show create database test_$1; show create database mysqltest;
Database Create Database Database Create Database
test_$1 CREATE DATABASE `test_$1` /*!40100 DEFAULT CHARACTER SET latin1 */ mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
drop table t1; drop table t1;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'test_$1' ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
drop database test_$1; drop database mysqltest;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'test_$1' ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
select * from test_$1.t1; select * from mysqltest.t1;
ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'test_$1' ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest'
show create database test_$1; show create database mysqltest;
ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'test_$1' ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest'
drop table test_$1.t1; drop table mysqltest.t1;
ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'test_$1' ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest'
drop database test_$1; drop database mysqltest;
ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'test_$1' ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest'
select * from test_$1.t1; select * from mysqltest.t1;
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'test_$1' ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest'
show create database test_$1; show create database mysqltest;
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'test_$1' ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest'
drop table test_$1.t1; drop table mysqltest.t1;
drop database test_$1; drop database mysqltest;
set names binary; set names binary;
delete from mysql.user delete from mysql.user
where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3'; where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
--disable_warnings --disable_warnings
drop table if exists t1,t2,t3; drop table if exists t1,t2,t3;
drop database if exists test_$1; drop database if exists mysqltest;
--enable_warnings --enable_warnings
create table t1 (b char(0)); create table t1 (b char(0));
...@@ -69,14 +69,14 @@ drop table 1ea10; ...@@ -69,14 +69,14 @@ drop table 1ea10;
create table t1 (t1.index int); create table t1 (t1.index int);
drop table t1; drop table t1;
# Test that we get warning for this # Test that we get warning for this
drop database if exists test_$1; drop database if exists mysqltest;
create database test_$1; create database mysqltest;
create table test_$1.$test1 (a$1 int, $b int, c$ int); create table mysqltest.$test1 (a$1 int, $b int, c$ int);
insert into test_$1.$test1 values (1,2,3); insert into mysqltest.$test1 values (1,2,3);
select a$1, $b, c$ from test_$1.$test1; select a$1, $b, c$ from mysqltest.$test1;
create table test_$1.test2$ (a int); create table mysqltest.test2$ (a int);
drop table test_$1.test2$; drop table mysqltest.test2$;
drop database test_$1; drop database mysqltest;
--error 1103 --error 1103
create table `` (a int); create table `` (a int);
...@@ -281,16 +281,16 @@ drop table t3; ...@@ -281,16 +281,16 @@ drop table t3;
show create table t3; show create table t3;
select * from t3; select * from t3;
drop table t2, t3; drop table t2, t3;
create database test_$1; create database mysqltest;
create table test_$1.t3 like t1; create table mysqltest.t3 like t1;
create temporary table t3 like test_$1.t3; create temporary table t3 like mysqltest.t3;
show create table t3; show create table t3;
create table t2 like t3; create table t2 like t3;
show create table t2; show create table t2;
select * from t2; select * from t2;
create table t3 like t1; create table t3 like t1;
--error 1050 --error 1050
create table t3 like test_$1.t3; create table t3 like mysqltest.t3;
--error 1044,1 --error 1044,1
create table non_existing_database.t1 like t1; create table non_existing_database.t1 like t1;
--error 1051 --error 1051
...@@ -301,7 +301,7 @@ create temporary table t3 like t1; ...@@ -301,7 +301,7 @@ create temporary table t3 like t1;
create table t3 like `a/a`; create table t3 like `a/a`;
drop table t1, t2, t3; drop table t1, t2, t3;
drop table t3; drop table t3;
drop database test_$1; drop database mysqltest;
# #
# Test default table type # Test default table type
...@@ -393,10 +393,10 @@ drop table t1, t2, t3; ...@@ -393,10 +393,10 @@ drop table t1, t2, t3;
# Bug #1209 # Bug #1209
# #
create database test_$1; create database mysqltest;
use test_$1; use mysqltest;
select database(); select database();
drop database test_$1; drop database mysqltest;
select database(); select database();
# Connect without a database # Connect without a database
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
drop database if exists test2; drop database if exists mysqltest;
--enable_warnings --enable_warnings
# #
...@@ -338,8 +338,8 @@ CREATE TABLE t1 ( ...@@ -338,8 +338,8 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413');
create database test2; create database mysqltest;
use test2; use mysqltest;
CREATE TABLE t2 ( CREATE TABLE t2 (
a bigint unsigned NOT NULL PRIMARY KEY, a bigint unsigned NOT NULL PRIMARY KEY,
...@@ -353,7 +353,5 @@ select b from test.t1, t2 where c = test.t1.attr2; ...@@ -353,7 +353,5 @@ select b from test.t1, t2 where c = test.t1.attr2;
select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a; select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a;
drop table test.t1, t2; drop table test.t1, t2;
drop database mysqltest;
drop database test2;
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
drop database if exists test2; drop database if exists mysqltest;
--enable_warnings --enable_warnings
# #
...@@ -214,8 +214,8 @@ select * from t1 order by a; ...@@ -214,8 +214,8 @@ select * from t1 order by a;
# multi db # multi db
create database test2; create database mysqltest;
use test2; use mysqltest;
CREATE TABLE t2 ( CREATE TABLE t2 (
a bigint unsigned NOT NULL PRIMARY KEY, a bigint unsigned NOT NULL PRIMARY KEY,
...@@ -271,5 +271,5 @@ select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) ...@@ -271,5 +271,5 @@ select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3)
from t1 order by a; from t1 order by a;
rollback; rollback;
select count(*) from t1; select count(*) from t1;
drop table t1;
--drop table t1; drop database mysqltest;
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
drop database if exists test2; drop database if exists mysqltest;
--enable_warnings --enable_warnings
# #
...@@ -263,8 +263,8 @@ CREATE TABLE t1 ( ...@@ -263,8 +263,8 @@ CREATE TABLE t1 (
attr1 INT NOT NULL attr1 INT NOT NULL
) ENGINE=ndbcluster; ) ENGINE=ndbcluster;
create database test2; create database mysqltest;
use test2; use mysqltest;
CREATE TABLE t2 ( CREATE TABLE t2 (
a bigint unsigned NOT NULL PRIMARY KEY, a bigint unsigned NOT NULL PRIMARY KEY,
...@@ -292,7 +292,6 @@ select count(*) from test.t1; ...@@ -292,7 +292,6 @@ select count(*) from test.t1;
select count(*) from t2; select count(*) from t2;
drop table test.t1, t2; drop table test.t1, t2;
drop database mysqltest;
drop database test2;
...@@ -350,11 +350,11 @@ prepare stmt4 from ' use test ' ; ...@@ -350,11 +350,11 @@ prepare stmt4 from ' use test ' ;
## create/drop database ## create/drop database
--error 1295 --error 1295
prepare stmt3 from ' create database drop_me '; prepare stmt3 from ' create database mysqltest ';
create database drop_me ; create database mysqltest ;
--error 1295 --error 1295
prepare stmt3 from ' drop database drop_me '; prepare stmt3 from ' drop database mysqltest ';
drop database drop_me ; drop database mysqltest ;
## grant/revoke + drop user ## grant/revoke + drop user
--error 1295 --error 1295
......
...@@ -6,41 +6,41 @@ ...@@ -6,41 +6,41 @@
source include/master-slave.inc; source include/master-slave.inc;
--disable_warnings --disable_warnings
drop database if exists test2; drop database if exists mysqltest2;
drop database if exists test3; drop database if exists mysqltest3;
--enable_warnings --enable_warnings
create database test2 character set latin2; create database mysqltest2 character set latin2;
set @@character_set_server=latin5; set @@character_set_server=latin5;
create database test3; create database mysqltest3;
--disable_query_log --disable_query_log
select "--- --master--" as ""; select "--- --master--" as "";
--enable_query_log --enable_query_log
show create database test2; show create database mysqltest2;
show create database test3; show create database mysqltest3;
sync_slave_with_master; sync_slave_with_master;
--disable_query_log --disable_query_log
select "--- --slave--" as ""; select "--- --slave--" as "";
--enable_query_log --enable_query_log
show create database test2; show create database mysqltest2;
show create database test3; show create database mysqltest3;
connection master; connection master;
set @@collation_server=armscii8_bin; set @@collation_server=armscii8_bin;
drop database test3; drop database mysqltest3;
create database test3; create database mysqltest3;
--disable_query_log --disable_query_log
select "--- --master--" as ""; select "--- --master--" as "";
--enable_query_log --enable_query_log
show create database test3; show create database mysqltest3;
sync_slave_with_master; sync_slave_with_master;
--disable_query_log --disable_query_log
select "--- --slave--" as ""; select "--- --slave--" as "";
--enable_query_log --enable_query_log
show create database test3; show create database mysqltest3;
connection master; connection master;
use test2; use mysqltest2;
create table t1 (a int auto_increment primary key, b varchar(100)); create table t1 (a int auto_increment primary key, b varchar(100));
set character_set_client=cp850, collation_connection=latin2_croatian_ci; set character_set_client=cp850, collation_connection=latin2_croatian_ci;
insert into t1 (b) values(@@character_set_server); insert into t1 (b) values(@@character_set_server);
...@@ -59,7 +59,7 @@ sync_slave_with_master; ...@@ -59,7 +59,7 @@ sync_slave_with_master;
--disable_query_log --disable_query_log
select "--- --slave--" as ""; select "--- --slave--" as "";
--enable_query_log --enable_query_log
select * from test2.t1 order by a; select * from mysqltest2.t1 order by a;
connection master; connection master;
set character_set_client=latin1, collation_connection=latin1_german1_ci; set character_set_client=latin1, collation_connection=latin1_german1_ci;
...@@ -77,7 +77,7 @@ sync_slave_with_master; ...@@ -77,7 +77,7 @@ sync_slave_with_master;
--disable_query_log --disable_query_log
select "--- --slave--" as ""; select "--- --slave--" as "";
--enable_query_log --enable_query_log
select * from test2.t1 order by a; select * from mysqltest2.t1 order by a;
# See if SET ONE_SHOT gets into binlog when LOAD DATA # See if SET ONE_SHOT gets into binlog when LOAD DATA
connection master; connection master;
...@@ -101,11 +101,11 @@ sync_slave_with_master; ...@@ -101,11 +101,11 @@ sync_slave_with_master;
--disable_query_log --disable_query_log
select "--- --slave--" as ""; select "--- --slave--" as "";
--enable_query_log --enable_query_log
select * from test2.t1 order by a; select * from mysqltest2.t1 order by a;
connection master; connection master;
drop database test2; drop database mysqltest2;
drop database test3; drop database mysqltest3;
show binlog events from 79; show binlog events from 79;
sync_slave_with_master; sync_slave_with_master;
......
source include/master-slave.inc; source include/master-slave.inc;
connection slave; connection slave;
create database test1; create database mysqltest;
connection master; connection master;
drop database if exists test1; drop database if exists mysqltest;
sync_slave_with_master; sync_slave_with_master;
# can't read dir # can't read dir
--replace_result "Errcode: 1" "Errcode: X" "Errcode: 2" "Errcode: X" --replace_result "Errcode: 1" "Errcode: X" "Errcode: 2" "Errcode: X"
--error 12 --error 12
show tables from test1; show tables from mysqltest;
connection slave; connection slave;
create table t1 (a int); create table t1 (a int);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2;
drop database if exists mysqltest;
--enable_warnings --enable_warnings
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c)); create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
...@@ -261,42 +262,42 @@ drop table t1, t2, t3; ...@@ -261,42 +262,42 @@ drop table t1, t2, t3;
# Test for bug #3342 SHOW CREATE DATABASE seems to require DROP privilege # Test for bug #3342 SHOW CREATE DATABASE seems to require DROP privilege
# #
create database test_$1; create database mysqltest;
show create database test_$1; show create database mysqltest;
create table test_$1.t1(a int); create table mysqltest.t1(a int);
insert into test_$1.t1 values(1); insert into mysqltest.t1 values(1);
grant select on `test_$1`.* to mysqltest_1@localhost; grant select on `mysqltest`.* to mysqltest_1@localhost;
grant usage on `test_$1`.* to mysqltest_2@localhost; grant usage on `mysqltest`.* to mysqltest_2@localhost;
grant drop on `test_$1`.* to mysqltest_3@localhost; grant drop on `mysqltest`.* to mysqltest_3@localhost;
connect (con1,localhost,mysqltest_1,,test_$1); connect (con1,localhost,mysqltest_1,,mysqltest);
connection con1; connection con1;
select * from t1; select * from t1;
show create database test_$1; show create database mysqltest;
--error 1044 --error 1044
drop table t1; drop table t1;
--error 1044 --error 1044
drop database test_$1; drop database mysqltest;
connect (con2,localhost,mysqltest_2,,test); connect (con2,localhost,mysqltest_2,,test);
connection con2; connection con2;
--error 1044 --error 1044
select * from test_$1.t1; select * from mysqltest.t1;
--error 1044 --error 1044
show create database test_$1; show create database mysqltest;
--error 1044 --error 1044
drop table test_$1.t1; drop table mysqltest.t1;
--error 1044 --error 1044
drop database test_$1; drop database mysqltest;
connect (con3,localhost,mysqltest_3,,test); connect (con3,localhost,mysqltest_3,,test);
connection con3; connection con3;
--error 1044 --error 1044
select * from test_$1.t1; select * from mysqltest.t1;
--error 1044 --error 1044
show create database test_$1; show create database mysqltest;
drop table test_$1.t1; drop table mysqltest.t1;
drop database test_$1; drop database mysqltest;
connection default; connection default;
set names binary; set names binary;
......
...@@ -908,7 +908,7 @@ public: ...@@ -908,7 +908,7 @@ public:
void reset(void) { charset()->cset->fill(charset(),ptr,field_length,' '); } void reset(void) { charset()->cset->fill(charset(),ptr,field_length,' '); }
int store(const char *to,uint length,CHARSET_INFO *charset); int store(const char *to,uint length,CHARSET_INFO *charset);
int store(longlong nr); int store(longlong nr);
int store(double nr) { return Field_str::store(nr); } int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -955,7 +955,7 @@ public: ...@@ -955,7 +955,7 @@ public:
uint32 key_length() const { return (uint32) field_length; } uint32 key_length() const { return (uint32) field_length; }
int store(const char *to,uint length,CHARSET_INFO *charset); int store(const char *to,uint length,CHARSET_INFO *charset);
int store(longlong nr); int store(longlong nr);
int store(double nr) { return Field_str::store(nr); } int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
......
...@@ -779,7 +779,8 @@ void unlock_global_read_lock(THD *thd) ...@@ -779,7 +779,8 @@ void unlock_global_read_lock(THD *thd)
(is_not_commit || \ (is_not_commit || \
global_read_lock_blocks_commit)) global_read_lock_blocks_commit))
bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh, bool is_not_commit) bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
bool is_not_commit)
{ {
const char *old_message; const char *old_message;
bool result= 0, need_exit_cond; bool result= 0, need_exit_cond;
......
...@@ -2138,7 +2138,10 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, ...@@ -2138,7 +2138,10 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
select list over other fields from the tables participating in select list over other fields from the tables participating in
this select in case of ambiguity. this select in case of ambiguity.
QQ: Why do we use simple strcmp for table name comparison here ? We use strcmp for table names and database names as these may be
case sensitive.
In cases where they are not case sensitive, they are always in lower
case.
*/ */
if (!my_strcasecmp(system_charset_info, item_field->field_name, if (!my_strcasecmp(system_charset_info, item_field->field_name,
field_name) && field_name) &&
...@@ -2157,10 +2160,12 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, ...@@ -2157,10 +2160,12 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
} }
found= li.ref(); found= li.ref();
*counter= i; *counter= i;
if (db_name)
break; // Perfect match
} }
} }
else if (!my_strcasecmp(system_charset_info, item_field->name, else if (!my_strcasecmp(system_charset_info, item_field->name,
field_name)) field_name))
{ {
/* /*
If table name was not given we should scan through aliases If table name was not given we should scan through aliases
...@@ -2230,7 +2235,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, ...@@ -2230,7 +2235,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
} }
if (found) if (found)
return found; return found;
else if (report_error != REPORT_EXCEPT_NOT_FOUND) if (report_error != REPORT_EXCEPT_NOT_FOUND)
{ {
if (report_error == REPORT_ALL_ERRORS) if (report_error == REPORT_ALL_ERRORS)
my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0), my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0),
......
...@@ -1041,7 +1041,7 @@ static int mysql_test_select(Prepared_statement *stmt, ...@@ -1041,7 +1041,7 @@ static int mysql_test_select(Prepared_statement *stmt,
THD *thd= stmt->thd; THD *thd= stmt->thd;
LEX *lex= stmt->lex; LEX *lex= stmt->lex;
SELECT_LEX_UNIT *unit= &lex->unit; SELECT_LEX_UNIT *unit= &lex->unit;
int result= 1;
DBUG_ENTER("mysql_test_select"); DBUG_ENTER("mysql_test_select");
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
...@@ -1087,13 +1087,12 @@ static int mysql_test_select(Prepared_statement *stmt, ...@@ -1087,13 +1087,12 @@ static int mysql_test_select(Prepared_statement *stmt,
goto err_prep; goto err_prep;
} }
} }
unit->cleanup(); result= 0; // ok
DBUG_RETURN(0);
err_prep: err_prep:
unit->cleanup(); unit->cleanup();
err: err:
DBUG_RETURN(1); DBUG_RETURN(result);
} }
......
...@@ -3220,7 +3220,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, ...@@ -3220,7 +3220,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
store_key **ref_key= j->ref.key_copy; store_key **ref_key= j->ref.key_copy;
byte *key_buff=j->ref.key_buff, *null_ref_key= 0; byte *key_buff=j->ref.key_buff, *null_ref_key= 0;
bool keyuse_uses_no_tables= true; bool keyuse_uses_no_tables= TRUE;
if (ftkey) if (ftkey)
{ {
j->ref.items[0]=((Item_func*)(keyuse->val))->key_item(); j->ref.items[0]=((Item_func*)(keyuse->val))->key_item();
...@@ -3240,7 +3240,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, ...@@ -3240,7 +3240,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
uint maybe_null= test(keyinfo->key_part[i].null_bit); uint maybe_null= test(keyinfo->key_part[i].null_bit);
j->ref.items[i]=keyuse->val; // Save for cond removal j->ref.items[i]=keyuse->val; // Save for cond removal
keyuse_uses_no_tables= keyuse_uses_no_tables & !keyuse->used_tables; keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables;
if (!keyuse->used_tables && if (!keyuse->used_tables &&
!(join->select_options & SELECT_DESCRIBE)) !(join->select_options & SELECT_DESCRIBE))
{ // Compare against constant { // Compare against constant
......
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