After merge fixes

Some bigger code changes was necessary becasue of the multi-table-update and the new HANDLER code


include/hash.h:
  Added back function that's was used in 4.0
mysql-test/r/delete.result:
  Update results after merge
mysql-test/r/flush_table.result:
  Update results after merge
mysql-test/r/func_str.result:
  Update results after merge
mysql-test/r/handler.result:
  Update results after merge
  Change is big becasue in MySQL 4.1 you are not allowed to qualify the handler alias with a databasename
mysql-test/r/multi_update.result:
  More startup cleanups
mysql-test/r/rename.result:
  More startup-cleanups
mysql-test/r/select.result:
  More startup cleanups
mysql-test/r/show_check.result:
  More startup-cleanups
mysql-test/t/ctype_latin1_de.test:
  Cleanup
mysql-test/t/derived.test:
  Portability fix
mysql-test/t/handler.test:
  Update results after merge
  Change is big becasue in MySQL 4.1 you are not allowed to qualify the handler alias with a databasename
mysql-test/t/multi_update.test:
  More startup cleanups
mysql-test/t/range.test:
  More comments
mysql-test/t/rename.test:
  More startup cleanups
mysql-test/t/select.test:
  More startup cleanups
mysql-test/t/show_check.test:
  More startup cleanups
mysql-test/t/type_timestamp.test:
  Add back test deleted during merge
sql/item_cmpfunc.cc:
  After merge fixes
sql/item_func.cc:
  Remove compiler warning
sql/mysql_priv.h:
  After merge fixes
sql/mysqld.cc:
  After merge fixes
sql/sql_acl.cc:
  More debugging
sql/sql_base.cc:
  After merge fixes
  (This fix was needed bacause of multi-table-update reopens tables)
sql/sql_handler.cc:
  After merge fixes
sql/sql_lex.h:
  After merge fixes
sql/sql_select.cc:
  After merge fixes
sql/sql_show.cc:
  After merge fixes
sql/sql_table.cc:
  After merge fixes
  Simple cleanup of mysql_discard_or_import_tablespace
sql/sql_update.cc:
  After merge fixes
  Rework mysql_multi_update to take into account derived tables.
sql/sql_yacc.yy:
  After merge fixes
This commit is contained in:
unknown 2004-10-07 10:50:13 +03:00
parent bbab9ec678
commit 96e7be58c8
31 changed files with 193 additions and 124 deletions

View File

@ -57,6 +57,7 @@ my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length);
void hash_replace(HASH *hash, uint idx, byte *new_row); void hash_replace(HASH *hash, uint idx, byte *new_row);
my_bool hash_check(HASH *hash); /* Only in debug library */ my_bool hash_check(HASH *hash); /* Only in debug library */
#define hash_clear(H) bzero((char*) (H),sizeof(*(H)))
#define hash_inited(H) ((H)->array.buffer != 0) #define hash_inited(H) ((H)->array.buffer != 0)
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -58,6 +58,17 @@ select count(*) from t1;
count(*) count(*)
0 0
drop table t1; drop table t1;
create table t1 (a int not null auto_increment primary key, b char(32));
insert into t1 (b) values ('apple'), ('apple');
select * from t1;
a b
1 apple
2 apple
delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
select * from t1;
a b
1 apple
drop table t1;
create table t11 (a int NOT NULL, b int, primary key (a)); create table t11 (a int NOT NULL, b int, primary key (a));
create table t12 (a int NOT NULL, b int, primary key (a)); create table t12 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a)); create table t2 (a int NOT NULL, b int, primary key (a));
@ -130,14 +141,3 @@ select * from t1;
a b a b
7 7 7 7
drop table t1; drop table t1;
create table t1 (a int not null auto_increment primary key, b char(32));
insert into t1 (b) values ('apple'), ('apple');
select * from t1;
a b
1 apple
2 apple
delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
select * from t1;
a b
1 apple
drop table t1;

View File

@ -42,11 +42,11 @@ table_id
test.t2 test.t2
handler t1 open as a1; handler t1 open as a1;
Not unique table/alias: 'a1' ERROR 42000: Not unique table/alias: 'a1'
handler t1 open as a2; handler t1 open as a2;
Not unique table/alias: 'a2' ERROR 42000: Not unique table/alias: 'a2'
handler t2 open; handler t2 open;
Not unique table/alias: 't2' ERROR 42000: Not unique table/alias: 't2'
handler a1 read first limit 9; handler a1 read first limit 9;
table_id table_id
test.t1 test.t1
@ -74,7 +74,6 @@ test.t2
flush table t2; flush table t2;
handler t2 close; handler t2 close;
ERROR 42S02: Unknown table 't2' in HANDLER
drop table t1; drop table t1;
drop table t2; drop table t2;
create table t1(table_id char(20) primary key); create table t1(table_id char(20) primary key);

View File

@ -321,6 +321,7 @@ trim(trailing 'foo' from 'foo')
select trim(leading 'foo' from 'foo'); select trim(leading 'foo' from 'foo');
trim(leading 'foo' from 'foo') trim(leading 'foo' from 'foo')
select 1=_latin1'1'; select 1=_latin1'1';
1=_latin1'1' 1=_latin1'1'
1 1

View File

@ -230,40 +230,36 @@ create table t1(table_id char(20) primary key);
insert into t1 values ('test.t1'); insert into t1 values ('test.t1');
insert into t1 values (''); insert into t1 values ('');
handler t1 open; handler t1 open;
Not unique table/alias: 't1' ERROR 42000: Not unique table/alias: 't1'
use test; use test;
handler test.t1 read first limit 9; handler test.t1 read first limit 9;
Unknown table 'test.t1' in HANDLER 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 'read first limit 9' at line 1
handler test_test.t1 read first limit 9; handler test_test.t1 read first limit 9;
table_id 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 'read first limit 9' at line 1
test_test.t1
handler t1 read first limit 9; handler t1 read first limit 9;
table_id table_id
test_test.t1 test_test.t1
handler test_test.t2 read first limit 9; handler test_test.t2 read first limit 9;
table_id 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 'read first limit 9' at line 1
test_test.t2
handler t2 read first limit 9; handler t2 read first limit 9;
table_id table_id
test_test.t2 test_test.t2
handler test_test.t1 close; handler test_test.t1 close;
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 'close' at line 1
handler t1 close; handler t1 close;
Unknown table 't1' in HANDLER
drop table test_test.t1; drop table test_test.t1;
handler test_test.t2 close; handler test_test.t2 close;
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 'close' at line 1
handler t2 close; handler t2 close;
Unknown table 't2' in HANDLER
drop table test_test.t2; drop table test_test.t2;
drop database test_test; drop database test_test;
use test; use test;
handler test.t1 close; handler test.t1 close;
Unknown table 'test.t1' in HANDLER 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 'close' at line 1
handler t1 close; handler t1 close;
Unknown table 't1' in HANDLER ERROR 42S02: Unknown table 't1' in HANDLER
drop table test.t1; drop table test.t1;
drop database if exists test_test; drop database if exists test_test;
drop table if exists t1; drop table if exists t1;
@ -291,20 +287,20 @@ insert into t1 values ('t1');
insert into t2 values ('t2'); insert into t2 values ('t2');
insert into t3 values ('t3'); insert into t3 values ('t3');
handler t1 open; handler t1 open;
Not unique table/alias: 't1' ERROR 42000: Not unique table/alias: 't1'
handler t2 open t1; handler t2 open t1;
Not unique table/alias: 't1' ERROR 42000: Not unique table/alias: 't1'
handler t3 open t1; handler t3 open t1;
Not unique table/alias: 't1' ERROR 42000: Not unique table/alias: 't1'
handler t1 read first limit 9; handler t1 read first limit 9;
c1 c1
test_test.t1 test_test.t1
handler test.t1 close; handler test.t1 close;
Unknown table 'test.t1' in HANDLER 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 'close' at line 1
handler test.t1 open h1; handler test.t1 open h1;
Not unique table/alias: 'h1' ERROR 42000: Not unique table/alias: 'h1'
handler test_test.t1 open h1; handler test_test.t1 open h1;
Not unique table/alias: 'h1' ERROR 42000: Not unique table/alias: 'h1'
handler test_test.t3 open h3; handler test_test.t3 open h3;
handler test.t1 open h2; handler test.t1 open h2;
handler t1 read first limit 9; handler t1 read first limit 9;
@ -319,24 +315,24 @@ t1
handler h3 read first limit 9; handler h3 read first limit 9;
c1 c1
test_test.t3 test_test.t3
handler test.h2 read first limit 9; handler h2 read first limit 9;
c1 c1
t1 t1
handler test.h1 close; handler test.h1 close;
Unknown table 'test.h1' in HANDLER 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 'close' at line 1
handler test_test.t1 close; handler t1 close;
handler test_test.h1 close; handler h1 close;
handler h2 close; handler h2 close;
handler t1 read first limit 9; handler t1 read first limit 9;
Unknown table 't1' in HANDLER ERROR 42S02: Unknown table 't1' in HANDLER
handler h1 read first limit 9; handler h1 read first limit 9;
Unknown table 'h1' in HANDLER ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9; handler h2 read first limit 9;
Unknown table 'h2' in HANDLER ERROR 42S02: Unknown table 'h2' in HANDLER
handler h3 read first limit 9; handler h3 read first limit 9;
c1 c1
test_test.t3 test_test.t3
handler test_test.h3 read first limit 9; handler h3 read first limit 9;
c1 c1
test_test.t3 test_test.t3
use test_test; use test_test;
@ -344,8 +340,8 @@ handler h3 read first limit 9;
c1 c1
test_test.t3 test_test.t3
handler test.h3 read first limit 9; handler test.h3 read first limit 9;
Unknown table 'test.h3' in HANDLER 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 'read first limit 9' at line 1
handler test_test.h3 close; handler h3 close;
use test; use test;
drop table t3; drop table t3;
drop table t2; drop table t2;
@ -383,7 +379,7 @@ c1
t5 t5
alter table t1 engine=MyISAM; alter table t1 engine=MyISAM;
handler h1 read first limit 9; handler h1 read first limit 9;
Unknown table 'h1' in HANDLER ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9; handler h2 read first limit 9;
c1 c1
t2 t2
@ -398,7 +394,7 @@ c1
t5 t5
alter table t5 engine=MyISAM; alter table t5 engine=MyISAM;
handler h1 read first limit 9; handler h1 read first limit 9;
Unknown table 'h1' in HANDLER ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9; handler h2 read first limit 9;
c1 c1
t2 t2
@ -409,20 +405,20 @@ handler h4 read first limit 9;
c1 c1
t4 t4
handler h5 read first limit 9; handler h5 read first limit 9;
Unknown table 'h5' in HANDLER ERROR 42S02: Unknown table 'h5' in HANDLER
alter table t3 engine=MyISAM; alter table t3 engine=MyISAM;
handler h1 read first limit 9; handler h1 read first limit 9;
Unknown table 'h1' in HANDLER ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9; handler h2 read first limit 9;
c1 c1
t2 t2
handler h3 read first limit 9; handler h3 read first limit 9;
Unknown table 'h3' in HANDLER ERROR 42S02: Unknown table 'h3' in HANDLER
handler h4 read first limit 9; handler h4 read first limit 9;
c1 c1
t4 t4
handler h5 read first limit 9; handler h5 read first limit 9;
Unknown table 'h5' in HANDLER ERROR 42S02: Unknown table 'h5' in HANDLER
handler h2 close; handler h2 close;
handler h4 close; handler h4 close;
handler t1 open as h1_1; handler t1 open as h1_1;
@ -439,11 +435,11 @@ c1
t1 t1
alter table t1 engine=MyISAM; alter table t1 engine=MyISAM;
handler h1_1 read first limit 9; handler h1_1 read first limit 9;
Unknown table 'h1_1' in HANDLER ERROR 42S02: Unknown table 'h1_1' in HANDLER
handler h1_2 read first limit 9; handler h1_2 read first limit 9;
Unknown table 'h1_2' in HANDLER ERROR 42S02: Unknown table 'h1_2' in HANDLER
handler h1_3 read first limit 9; handler h1_3 read first limit 9;
Unknown table 'h1_3' in HANDLER ERROR 42S02: Unknown table 'h1_3' in HANDLER
drop table t1; drop table t1;
drop table t2; drop table t2;
drop table t3; drop table t3;

View File

@ -1,5 +1,8 @@
drop table if exists t1,t2,t3; drop table if exists t1,t2,t3;
drop database if exists mysqltest; drop database if exists mysqltest;
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user=_binary'mysqltest_1';
create table t1(id1 int not null auto_increment primary key, t char(12)); create table t1(id1 int not null auto_increment primary key, t char(12));
create table t2(id2 int not null, t char(12)); create table t2(id2 int not null, t char(12));
create table t3(id3 int not null, t char(12), index(id3)); create table t3(id3 int not null, t char(12), index(id3));
@ -152,7 +155,6 @@ ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n; UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n; UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
unlock tables; unlock tables;
LOCK TABLES t1 write, t2 write; LOCK TABLES t1 write, t2 write;
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n; UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;

View File

@ -1,5 +1,5 @@
drop table if exists t0,t1,t2,t3,t4; drop table if exists t0,t1,t2,t3,t4;
drop table if exists t0,t5,t6,t7,t8,t9; drop table if exists t0,t5,t6,t7,t8,t9,t1_1,t1_2,t9_1,t9_2;
create table t0 SELECT 1,"table 1"; create table t0 SELECT 1,"table 1";
create table t2 SELECT 2,"table 2"; create table t2 SELECT 2,"table 2";
create table t3 SELECT 3,"table 3"; create table t3 SELECT 3,"table 3";

View File

@ -1,4 +1,5 @@
drop table if exists t1,t2,t3,t4; drop table if exists t1,t2,t3,t4;
drop table if exists t1_1,t1_2,t9_1,t9_2;
CREATE TABLE t1 ( CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL

View File

@ -1,5 +1,8 @@
drop table if exists t1,t2; drop table if exists t1,t2;
drop database if exists mysqltest; drop database if exists mysqltest;
delete from mysql.user where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
delete from mysql.db where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
flush privileges;
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;

View File

@ -89,7 +89,6 @@ drop table t1;
# #
# Bug #5447 Select does not find records # Bug #5447 Select does not find records
# #
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
autor varchar(80) NOT NULL default '', autor varchar(80) NOT NULL default '',
PRIMARY KEY (autor) PRIMARY KEY (autor)

View File

@ -101,7 +101,7 @@ SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1;
# #
# Connect without a database # Connect without a database
create table t1 select 1 as a; create table t1 select 1 as a;
connect (con1,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,master.sock); connect (con1,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK);
connection con1; connection con1;
--error 1046 --error 1046
select 2 as a from (select * from t1) b; select 2 as a from (select * from t1) b;

View File

@ -174,30 +174,34 @@ handler t1 open;
# Check accesibility of all the tables. # Check accesibility of all the tables.
# #
use test; use test;
--error 1109; --error 1064
handler test.t1 read first limit 9; handler test.t1 read first limit 9;
--error 1064
handler test_test.t1 read first limit 9; handler test_test.t1 read first limit 9;
handler t1 read first limit 9; handler t1 read first limit 9;
--error 1064
handler test_test.t2 read first limit 9; handler test_test.t2 read first limit 9;
handler t2 read first limit 9; handler t2 read first limit 9;
# #
# Cleanup. # Cleanup.
# #
--error 1064
handler test_test.t1 close; handler test_test.t1 close;
--error 1109;
handler t1 close; handler t1 close;
drop table test_test.t1; drop table test_test.t1;
--error 1064
handler test_test.t2 close; handler test_test.t2 close;
--error 1109;
handler t2 close; handler t2 close;
drop table test_test.t2; drop table test_test.t2;
drop database test_test; drop database test_test;
# #
use test; use test;
--error 1109; --error 1064
handler test.t1 close; handler test.t1 close;
--error 1109; --error 1109
handler t1 close; handler t1 close;
drop table test.t1; drop table test.t1;
@ -234,7 +238,7 @@ handler t2 open t1;
--error 1066 --error 1066
handler t3 open t1; handler t3 open t1;
handler t1 read first limit 9; handler t1 read first limit 9;
--error 1109 --error 1064
handler test.t1 close; handler test.t1 close;
--error 1066 --error 1066
handler test.t1 open h1; handler test.t1 open h1;
@ -246,11 +250,11 @@ handler t1 read first limit 9;
handler h1 read first limit 9; handler h1 read first limit 9;
handler h2 read first limit 9; handler h2 read first limit 9;
handler h3 read first limit 9; handler h3 read first limit 9;
handler test.h2 read first limit 9; handler h2 read first limit 9;
--error 1109 --error 1064
handler test.h1 close; handler test.h1 close;
handler test_test.t1 close; handler t1 close;
handler test_test.h1 close; handler h1 close;
handler h2 close; handler h2 close;
--error 1109 --error 1109
handler t1 read first limit 9; handler t1 read first limit 9;
@ -259,12 +263,12 @@ handler h1 read first limit 9;
--error 1109 --error 1109
handler h2 read first limit 9; handler h2 read first limit 9;
handler h3 read first limit 9; handler h3 read first limit 9;
handler test_test.h3 read first limit 9; handler h3 read first limit 9;
use test_test; use test_test;
handler h3 read first limit 9; handler h3 read first limit 9;
--error 1109 --error 1064
handler test.h3 read first limit 9; handler test.h3 read first limit 9;
handler test_test.h3 close; handler h3 close;
use test; use test;
drop table t3; drop table t3;
drop table t2; drop table t2;

View File

@ -5,6 +5,11 @@
--disable_warnings --disable_warnings
drop table if exists t1,t2,t3; drop table if exists t1,t2,t3;
drop database if exists mysqltest; drop database if exists mysqltest;
--error 0,1141
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
--error 0,1141
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user=_binary'mysqltest_1';
--enable_warnings --enable_warnings
create table t1(id1 int not null auto_increment primary key, t char(12)); create table t1(id1 int not null auto_increment primary key, t char(12));
@ -383,10 +388,10 @@ select * from t2;
drop table t1, t2; drop table t1, t2;
# #
# prevelege chexk for multiupdate with other tables # privilege check for multiupdate with other tables
# #
connect (root,localhost,root,,test,$MASTER_MYPORT,master.sock); connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection root; connection root;
--disable_warnings --disable_warnings
create database mysqltest; create database mysqltest;
@ -396,7 +401,7 @@ create table mysqltest.t2 (a int, b int, primary key (a));
create table mysqltest.t3 (a int, b int, primary key (a)); create table mysqltest.t3 (a int, b int, primary key (a));
grant select on mysqltest.* to mysqltest_1@localhost; grant select on mysqltest.* to mysqltest_1@localhost;
grant update on mysqltest.t1 to mysqltest_1@localhost; grant update on mysqltest.t1 to mysqltest_1@localhost;
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,master.sock); connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
connection user1; connection user1;
update t1, t2 set t1.b=1 where t1.a=t2.a; update t1, t2 set t1.b=1 where t1.a=t2.a;
update t1, t2 set t1.b=(select t3.b from t3 where t1.a=t3.a) where t1.a=t2.a; update t1, t2 set t1.b=(select t3.b from t3 where t1.a=t3.a) where t1.a=t2.a;

View File

@ -423,6 +423,9 @@ select count(*) from t1 where x=0;
select count(*) from t1 where x<0; select count(*) from t1 where x<0;
select count(*) from t1 where x < -16; select count(*) from t1 where x < -16;
select count(*) from t1 where x = -16; select count(*) from t1 where x = -16;
# The following query returns wrong value because the range optimizer can't
# handle search on a signed value for an unsigned parameter. This will be fixed in
# 5.0
select count(*) from t1 where x > -16; select count(*) from t1 where x > -16;
select count(*) from t1 where x = 18446744073709551601; select count(*) from t1 where x = 18446744073709551601;

View File

@ -5,7 +5,7 @@
--disable_warnings --disable_warnings
drop table if exists t0,t1,t2,t3,t4; drop table if exists t0,t1,t2,t3,t4;
# Clear up from other tests (to ensure that SHOW TABLES below is right) # Clear up from other tests (to ensure that SHOW TABLES below is right)
drop table if exists t0,t5,t6,t7,t8,t9; drop table if exists t0,t5,t6,t7,t8,t9,t1_1,t1_2,t9_1,t9_2;
--enable_warnings --enable_warnings
create table t0 SELECT 1,"table 1"; create table t0 SELECT 1,"table 1";

View File

@ -8,6 +8,8 @@
--disable_warnings --disable_warnings
drop table if exists t1,t2,t3,t4; drop table if exists t1,t2,t3,t4;
# The following may be left from older tests
drop table if exists t1_1,t1_2,t9_1,t9_2;
--enable_warnings --enable_warnings
CREATE TABLE t1 ( CREATE TABLE t1 (

View File

@ -5,6 +5,10 @@
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2;
drop database if exists mysqltest; drop database if exists mysqltest;
delete from mysql.user where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
delete from mysql.db where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
flush privileges;
--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));

View File

@ -62,6 +62,17 @@ INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
SELECT * FROM t1; SELECT * FROM t1;
drop table t1; drop table t1;
create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
t14 timestamp(14));
insert t1 values (0,0,0,0,0,0,0),
("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59");
select * from t1;
select * from t1;
drop table t1;
# #
# Let us check if we properly treat wrong datetimes and produce proper warnings # Let us check if we properly treat wrong datetimes and produce proper warnings
# (for both strings and numbers) # (for both strings and numbers)
@ -270,7 +281,6 @@ drop table t1;
# Test for bug #4131, TIMESTAMP columns missing minutes and seconds when # Test for bug #4131, TIMESTAMP columns missing minutes and seconds when
# using GROUP BY in @@new=1 mode. # using GROUP BY in @@new=1 mode.
# #
set new=1;
create table t1 (a char(2), t timestamp); create table t1 (a char(2), t timestamp);
insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'), insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'),
('b', '2004-02-01 00:00:00'); ('b', '2004-02-01 00:00:00');

View File

@ -1166,8 +1166,8 @@ Item_func_nullif::val_str(String *str)
bool bool
Item_func_nullif::is_null() Item_func_nullif::is_null()
{ {
if (!(this->*cmp_func)()) if (!cmp.compare())
return null_value=1; return (null_value=1);
return 0; return 0;
} }

View File

@ -2736,6 +2736,8 @@ void Item_func_get_user_var::fix_length_and_dec()
case STRING_RESULT: case STRING_RESULT:
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
break; break;
case ROW_RESULT: // Keep compiler happy
break;
} }
} }
else else

View File

@ -729,6 +729,7 @@ void wait_for_refresh(THD *thd);
int open_tables(THD *thd, TABLE_LIST *tables, uint *counter); int open_tables(THD *thd, TABLE_LIST *tables, uint *counter);
int simple_open_n_lock_tables(THD *thd,TABLE_LIST *tables); int simple_open_n_lock_tables(THD *thd,TABLE_LIST *tables);
int open_and_lock_tables(THD *thd,TABLE_LIST *tables); int open_and_lock_tables(THD *thd,TABLE_LIST *tables);
void relink_tables_for_derived(THD *thd);
int lock_tables(THD *thd, TABLE_LIST *tables, uint counter); int lock_tables(THD *thd, TABLE_LIST *tables, uint counter);
TABLE *open_temporary_table(THD *thd, const char *path, const char *db, TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
const char *table_name, bool link_in_list); const char *table_name, bool link_in_list);

View File

@ -2118,7 +2118,7 @@ static void check_data_home(const char *path)
/* ARGSUSED */ /* ARGSUSED */
! extern "C" int my_message_sql(uint error, const char *str, myf MyFlags) extern "C" int my_message_sql(uint error, const char *str, myf MyFlags)
{ {
THD *thd; THD *thd;
DBUG_ENTER("my_message_sql"); DBUG_ENTER("my_message_sql");
@ -2132,7 +2132,11 @@ static void check_data_home(const char *path)
if (thd->lex->current_select && if (thd->lex->current_select &&
thd->lex->current_select->no_error && !thd->is_fatal_error) thd->lex->current_select->no_error && !thd->is_fatal_error)
{ {
DBUG_PRINT("error", ("above error converted to warning")); DBUG_PRINT("error", ("Error converted to warning: current_select: no_error %d fatal_error: %d",
(thd->lex->current_select ?
thd->lex->current_select->no_error : 0),
(int) thd->is_fatal_error));
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str); push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str);
} }
else else

View File

@ -2699,10 +2699,11 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
{ {
TABLE_LIST *table; TABLE_LIST *table;
char *user = thd->priv_user; char *user = thd->priv_user;
DBUG_ENTER("check_grant");
want_access &= ~thd->master_access; want_access &= ~thd->master_access;
if (!want_access) if (!want_access)
return 0; // ok DBUG_RETURN(0); // ok
rw_rdlock(&LOCK_grant); rw_rdlock(&LOCK_grant);
for (table= tables; table && number--; table= table->next) for (table= tables; table && number--; table= table->next)
@ -2739,7 +2740,7 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
} }
} }
rw_unlock(&LOCK_grant); rw_unlock(&LOCK_grant);
return 0; DBUG_RETURN(0);
err: err:
rw_unlock(&LOCK_grant); rw_unlock(&LOCK_grant);
@ -2770,7 +2771,7 @@ err:
thd->host_or_ip, thd->host_or_ip,
table ? table->real_name : "unknown"); table ? table->real_name : "unknown");
} }
return 1; DBUG_RETURN(1);
} }

View File

@ -1695,10 +1695,18 @@ int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
uint counter; uint counter;
if (open_tables(thd, tables, &counter) || lock_tables(thd, tables, counter)) if (open_tables(thd, tables, &counter) || lock_tables(thd, tables, counter))
DBUG_RETURN(-1); /* purecov: inspected */ DBUG_RETURN(-1); /* purecov: inspected */
relink_tables_for_derived(thd);
DBUG_RETURN(mysql_handle_derived(thd->lex));
}
/* /*
Let us propagate pointers to open tables from global table list Let us propagate pointers to open tables from global table list
to table lists in particular selects if needed. to table lists in particular selects if needed.
*/ */
void relink_tables_for_derived(THD *thd)
{
if (thd->lex->all_selects_list->next_select_in_list() || if (thd->lex->all_selects_list->next_select_in_list() ||
thd->lex->time_zone_tables_used) thd->lex->time_zone_tables_used)
{ {
@ -1711,7 +1719,6 @@ int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
if (cursor->table_list) if (cursor->table_list)
cursor->table= cursor->table_list->table; cursor->table= cursor->table_list->table;
} }
DBUG_RETURN(mysql_handle_derived(thd->lex));
} }
@ -1751,7 +1758,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count)
if (!table->derived) if (!table->derived)
*(ptr++)= table->table; *(ptr++)= table->table;
} }
if (!(thd->lock=mysql_lock_tables(thd,start,count))) if (!(thd->lock=mysql_lock_tables(thd,start, (uint) (ptr - start))))
return -1; /* purecov: inspected */ return -1; /* purecov: inspected */
} }
else else

View File

@ -159,7 +159,8 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
/* /*
HASH entries are of type TABLE_LIST. HASH entries are of type TABLE_LIST.
*/ */
if (hash_init(&thd->handler_tables_hash, HANDLER_TABLES_HASH_SIZE, 0, 0, if (hash_init(&thd->handler_tables_hash, &my_charset_latin1,
HANDLER_TABLES_HASH_SIZE, 0, 0,
(hash_get_key) mysql_ha_hash_get_key, (hash_get_key) mysql_ha_hash_get_key,
(hash_free_key) mysql_ha_hash_free, 0)) (hash_free_key) mysql_ha_hash_free, 0))
goto err; goto err;
@ -223,7 +224,7 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
memcpy(hash_tables->alias, tables->alias, aliaslen); memcpy(hash_tables->alias, tables->alias, aliaslen);
/* add to hash */ /* add to hash */
if (hash_insert(&thd->handler_tables_hash, (byte*) hash_tables)) if (my_hash_insert(&thd->handler_tables_hash, (byte*) hash_tables))
{ {
mysql_ha_close(thd, tables); mysql_ha_close(thd, tables);
goto err; goto err;
@ -293,7 +294,7 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
{ {
if (*table_ptr) if (*table_ptr)
{ {
table_ptr->file->ha_index_or_rnd_end(); (*table_ptr)->file->ha_index_or_rnd_end();
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
if (close_thread_table(thd, table_ptr)) if (close_thread_table(thd, table_ptr))
{ {
@ -582,7 +583,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
} }
ok: ok:
mysql_unlock_tables(thd,lock); mysql_unlock_tables(thd,lock);
send_eof(&thd->net); send_eof(thd);
DBUG_PRINT("exit",("mysql_ha_read: OK")); DBUG_PRINT("exit",("mysql_ha_read: OK"));
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
@ -645,8 +646,10 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags)
while (*table_ptr) while (*table_ptr)
{ {
if ((! *tmp_tables->db || if ((! *tmp_tables->db ||
! my_strcasecmp((*table_ptr)->table_cache_key, tmp_tables->db)) && ! my_strcasecmp(&my_charset_latin1, (*table_ptr)->table_cache_key,
! my_strcasecmp((*table_ptr)->real_name, tmp_tables->real_name)) tmp_tables->db)) &&
! my_strcasecmp(&my_charset_latin1, (*table_ptr)->real_name,
tmp_tables->real_name))
{ {
DBUG_PRINT("info",("mysql_ha_flush: *table_ptr '%s'.'%s' as '%s'", DBUG_PRINT("info",("mysql_ha_flush: *table_ptr '%s'.'%s' as '%s'",
(*table_ptr)->table_cache_key, (*table_ptr)->table_cache_key,
@ -725,7 +728,7 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, int mode_flags)
} }
} }
table_ptr->file->ha_index_or_rnd_end(); (*table_ptr)->file->ha_index_or_rnd_end();
if (close_thread_table(thd, table_ptr)) if (close_thread_table(thd, table_ptr))
{ {
/* Tell threads waiting for refresh that something has happened */ /* Tell threads waiting for refresh that something has happened */

View File

@ -599,7 +599,7 @@ typedef struct st_lex
USER_RESOURCES mqh; USER_RESOURCES mqh;
ulong thread_id,type; ulong thread_id,type;
enum_sql_command sql_command; enum_sql_command sql_command;
thr_lock_type lock_option; thr_lock_type lock_option, multi_lock_option;
enum SSL_type ssl_type; /* defined in violite.h */ enum SSL_type ssl_type; /* defined in violite.h */
enum my_lex_states next_state; enum my_lex_states next_state;
enum enum_duplicates duplicates; enum enum_duplicates duplicates;

View File

@ -7188,7 +7188,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
if (keys.is_set(nr)) if (keys.is_set(nr))
{ {
int flag; int flag;
if (flag=test_if_order_by_key(order, table, nr, &not_used)) if ((flag= test_if_order_by_key(order, table, nr, &not_used)))
{ {
if (!no_changes) if (!no_changes)
{ {

View File

@ -1,5 +1,4 @@
/* Copyright (C) 2000 MySQL AB /* Copyright (C) 2000-2004 MySQL AB
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -2265,8 +2265,10 @@ int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
&handler::check)); &handler::check));
} }
/* table_list should contain just one table */ /* table_list should contain just one table */
int mysql_discard_or_import_tablespace(THD *thd, static int
mysql_discard_or_import_tablespace(THD *thd,
TABLE_LIST *table_list, TABLE_LIST *table_list,
enum tablespace_op_type tablespace_op) enum tablespace_op_type tablespace_op)
{ {
@ -2275,21 +2277,20 @@ int mysql_discard_or_import_tablespace(THD *thd,
int error; int error;
DBUG_ENTER("mysql_discard_or_import_tablespace"); DBUG_ENTER("mysql_discard_or_import_tablespace");
/* Note that DISCARD/IMPORT TABLESPACE always is the only operation in an /*
ALTER TABLE */ Note that DISCARD/IMPORT TABLESPACE always is the only operation in an
ALTER TABLE
*/
thd->proc_info="discard_or_import_tablespace"; thd->proc_info="discard_or_import_tablespace";
if (tablespace_op == DISCARD_TABLESPACE) discard= test(tablespace_op == DISCARD_TABLESPACE);
discard = TRUE;
else
discard = FALSE;
thd->tablespace_op=TRUE; /* we set this flag so that ha_innobase::open
and ::external_lock() do not complain when we
lock the table */
mysql_ha_close(thd, table_list, /*dont_send_ok*/ 1, /*dont_lock*/ 1);
/*
We set this flag so that ha_innobase::open and ::external_lock() do
not complain when we lock the table
*/
thd->tablespace_op= TRUE;
if (!(table=open_ltable(thd,table_list,TL_WRITE))) if (!(table=open_ltable(thd,table_list,TL_WRITE)))
{ {
thd->tablespace_op=FALSE; thd->tablespace_op=FALSE;
@ -2303,8 +2304,10 @@ int mysql_discard_or_import_tablespace(THD *thd,
if (error) if (error)
goto err; goto err;
/* The 0 in the call below means 'not in a transaction', which means /*
immediate invalidation; that is probably what we wish here */ The 0 in the call below means 'not in a transaction', which means
immediate invalidation; that is probably what we wish here
*/
query_cache_invalidate3(thd, table_list, 0); query_cache_invalidate3(thd, table_list, 0);
/* The ALTER TABLE is always in its own transaction */ /* The ALTER TABLE is always in its own transaction */

View File

@ -303,6 +303,7 @@ int mysql_update(THD *thd,
else if (handle_duplicates != DUP_IGNORE || else if (handle_duplicates != DUP_IGNORE ||
error != HA_ERR_FOUND_DUPP_KEY) error != HA_ERR_FOUND_DUPP_KEY)
{ {
thd->fatal_error(); // Force error message
table->file->print_error(error,MYF(0)); table->file->print_error(error,MYF(0));
error= 1; error= 1;
break; break;
@ -484,6 +485,8 @@ int mysql_multi_update(THD *thd,
TABLE_LIST *tl; TABLE_LIST *tl;
TABLE_LIST *update_list= (TABLE_LIST*) thd->lex->select_lex.table_list.first; TABLE_LIST *update_list= (TABLE_LIST*) thd->lex->select_lex.table_list.first;
List<Item> total_list; List<Item> total_list;
const bool using_lock_tables= thd->locked_tables != 0;
bool initialized_dervied= 0;
DBUG_ENTER("mysql_multi_update"); DBUG_ENTER("mysql_multi_update");
select_lex->select_limit= HA_POS_ERROR; select_lex->select_limit= HA_POS_ERROR;
@ -495,15 +498,24 @@ int mysql_multi_update(THD *thd,
for (;;) for (;;)
{ {
table_map update_tables, derived_tables=0; table_map update_tables, derived_tables=0;
uint tnr, counter; uint tnr, table_count;
if ((res=open_tables(thd,table_list, &counter))) if ((res=open_tables(thd, table_list, &table_count)))
DBUG_RETURN(res); DBUG_RETURN(res);
/* Only need to call lock_tables if we are not using LOCK TABLES */ /* Only need to call lock_tables if we are not using LOCK TABLES */
if (!using_lock_tables && ((res= lock_tables(thd, table_list)))) if (!using_lock_tables &&
((res= lock_tables(thd, table_list, table_count))))
DBUG_RETURN(res); DBUG_RETURN(res);
if (!initialized_dervied)
{
initialized_dervied= 1;
relink_tables_for_derived(thd);
if ((res= mysql_handle_derived(thd->lex)))
DBUG_RETURN(res);
}
/* /*
Ensure that we have update privilege for all tables and columns in the Ensure that we have update privilege for all tables and columns in the
SET part SET part
@ -558,7 +570,7 @@ int mysql_multi_update(THD *thd,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
DBUG_PRINT("info",("setting table `%s` for update", tl->alias)); DBUG_PRINT("info",("setting table `%s` for update", tl->alias));
tl->lock_type= thd->lex.lock_option; tl->lock_type= thd->lex->multi_lock_option;
tl->updating= 1; tl->updating= 1;
} }
else else
@ -569,6 +581,8 @@ int mysql_multi_update(THD *thd,
} }
if (tl->derived) if (tl->derived)
derived_tables|= table->map; derived_tables|= table->map;
else if (!using_lock_tables)
tl->table->reginfo.lock_type= tl->lock_type;
} }
if (thd->lex->derived_tables && (update_tables & derived_tables)) if (thd->lex->derived_tables && (update_tables & derived_tables))
@ -586,7 +600,7 @@ int mysql_multi_update(THD *thd,
} }
/* Relock the tables with the correct modes */ /* Relock the tables with the correct modes */
res= lock_tables(thd,table_list); res= lock_tables(thd, table_list, table_count);
if (using_lock_tables) if (using_lock_tables)
{ {
if (res) if (res)
@ -608,7 +622,7 @@ int mysql_multi_update(THD *thd,
item->cleanup(); item->cleanup();
} }
} }
if (setup_fields(thd, table_list, *fields, 1, 0, 0)) if (setup_fields(thd, 0, update_list, *fields, 1, 0, 0))
DBUG_RETURN(-1); DBUG_RETURN(-1);
/* /*
If lock succeded and the table map didn't change since the above lock If lock succeded and the table map didn't change since the above lock
@ -624,9 +638,7 @@ int mysql_multi_update(THD *thd,
close_thread_tables(thd); close_thread_tables(thd);
} }
/* /* Setup timestamp handling */
Setup timestamp handling
*/
for (tl= update_list; tl; tl= tl->next) for (tl= update_list; tl; tl= tl->next)
{ {
TABLE *table= tl->table; TABLE *table= tl->table;
@ -634,6 +646,9 @@ int mysql_multi_update(THD *thd,
if (table->timestamp_field && if (table->timestamp_field &&
table->timestamp_field->query_id == thd->query_id) table->timestamp_field->query_id == thd->query_id)
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
/* We only need SELECT privilege for columns in the values list */
table->grant.want_privilege= (SELECT_ACL & ~table->grant.privilege);
} }
if (!(result=new multi_update(thd, update_list, fields, values, if (!(result=new multi_update(thd, update_list, fields, values,
@ -994,6 +1009,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
if (handle_duplicates != DUP_IGNORE || if (handle_duplicates != DUP_IGNORE ||
error != HA_ERR_FOUND_DUPP_KEY) error != HA_ERR_FOUND_DUPP_KEY)
{ {
thd->fatal_error(); // Force error message
table->file->print_error(error,MYF(0)); table->file->print_error(error,MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -1149,7 +1165,10 @@ int multi_update::do_updates(bool from_send_error)
err: err:
if (!from_send_error) if (!from_send_error)
{
thd->fatal_error();
table->file->print_error(local_error,MYF(0)); table->file->print_error(local_error,MYF(0));
}
(void) table->file->ha_rnd_end(); (void) table->file->ha_rnd_end();
(void) tmp_table->file->ha_rnd_end(); (void) tmp_table->file->ha_rnd_end();

View File

@ -4169,7 +4169,7 @@ update:
if (lex->select_lex.table_list.elements > 1) if (lex->select_lex.table_list.elements > 1)
{ {
lex->sql_command= SQLCOM_UPDATE_MULTI; lex->sql_command= SQLCOM_UPDATE_MULTI;
lex->lock_option= $3; lex->multi_lock_option= $3;
} }
else if (lex->select_lex.get_table_list()->derived) else if (lex->select_lex.get_table_list()->derived)
{ {