Commit 74519b98 authored by unknown's avatar unknown
Browse files

Merge bk-internal.mysql.com:/home/bk/mysql-5.1-engines

into  chilla.local:/home/mydev/mysql-5.1-axmrg


sql/mysql_priv.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_servers.h:
  Auto merged
storage/federated/ha_federated.cc:
  Auto merged
storage/heap/ha_heap.cc:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
sql/sql_servers.cc:
  Manual merge
parents 8f93150d 548aad25
Loading
Loading
Loading
Loading
+185 −10
Original line number Diff line number Diff line
@@ -20,6 +20,14 @@ CREATE TABLE first_db.t1 (
`name` varchar(64) NOT NULL default ''
    )
DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS first_db.t2;
Warnings:
Note	1051	Unknown table 't2'
CREATE TABLE first_db.t2 (
`id` int(20) NOT NULL,
`name` varchar(64) NOT NULL default ''
    )
DEFAULT CHARSET=latin1;
use second_db;
DROP TABLE IF EXISTS second_db.t1;
Warnings:
@@ -29,6 +37,14 @@ CREATE TABLE second_db.t1 (
`name` varchar(64) NOT NULL default ''
    )
DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS second_db.t2;
Warnings:
Note	1051	Unknown table 't2'
CREATE TABLE second_db.t2 (
`id` int(20) NOT NULL,
`name` varchar(64) NOT NULL default ''
    )
DEFAULT CHARSET=latin1;
drop server if exists 'server_one';
create server 'server_one' foreign data wrapper 'mysql' options
(HOST '127.0.0.1',
@@ -60,10 +76,10 @@ CREATE TABLE federated.old (
    )
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/first_db/t1';
INSERT INTO federated.old (id, name) values (1, 'federated.old url');
INSERT INTO federated.old (id, name) values (1, 'federated.old-> first_db.t1, url format');
SELECT * FROM federated.old;
id	name
1	federated.old url
1	federated.old-> first_db.t1, url format
DROP TABLE IF EXISTS federated.old2;
Warnings:
Note	1051	Unknown table 'old2'
@@ -72,8 +88,37 @@ CREATE TABLE federated.old2 (
`name` varchar(64) NOT NULL default ''
    )
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/first_db/t2';
INSERT INTO federated.old2 (id, name) values (1, 'federated.old2-> first_db.t2, url format');
SELECT * FROM federated.old2;
id	name
1	federated.old2-> first_db.t2, url format
DROP TABLE IF EXISTS federated.urldb2t1;
Warnings:
Note	1051	Unknown table 'urldb2t1'
CREATE TABLE federated.urldb2t1 (
`id` int(20) NOT NULL,
`name` varchar(64) NOT NULL default ''
    )
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/second_db/t1';
INSERT INTO federated.old2 (id, name) values (1, 'federated.old2 url');
INSERT INTO federated.urldb2t1 (id, name) values (1, 'federated.urldb2t1 -> second_db.t1, url format');
SELECT * FROM federated.urldb2t1;
id	name
1	federated.urldb2t1 -> second_db.t1, url format
DROP TABLE IF EXISTS federated.urldb2t2;
Warnings:
Note	1051	Unknown table 'urldb2t2'
CREATE TABLE federated.urldb2t2 (
`id` int(20) NOT NULL,
`name` varchar(64) NOT NULL default ''
    )
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/second_db/t2';
INSERT INTO federated.urldb2t2 (id, name) values (1, 'federated.urldb2t2 -> second_db.t2, url format');
SELECT * FROM federated.urldb2t2;
id	name
1	federated.urldb2t2 -> second_db.t2, url format
DROP TABLE IF EXISTS federated.t1;
Warnings:
Note	1051	Unknown table 't1'
@@ -83,18 +128,38 @@ CREATE TABLE federated.t1 (
    )
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='server_one';
INSERT INTO federated.t1 (id, name) values (1, 'server_one, new scheme');
INSERT INTO federated.t1 (id, name) values (1, 'server_one, new scheme, first_db.t1');
SELECT * FROM federated.t1;
id	name
1	federated.old url
1	server_one, new scheme
1	federated.old-> first_db.t1, url format
1	server_one, new scheme, first_db.t1
DROP TABLE IF EXISTS federated.whatever;
Warnings:
Note	1051	Unknown table 'whatever'
CREATE TABLE federated.whatever (
`id` int(20) NOT NULL,
`name` varchar(64) NOT NULL default ''
    )
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='server_one/t1';
INSERT INTO federated.whatever (id, name) values (1, 'server_one, new scheme, whatever, first_db.t1');
SELECT * FROM federated.whatever;
id	name
1	federated.old-> first_db.t1, url format
1	server_one, new scheme, first_db.t1
1	server_one, new scheme, whatever, first_db.t1
ALTER SERVER 'server_one' options(DATABASE 'second_db');
flush tables;
INSERT INTO federated.t1 (id, name) values (1, 'server_two, new scheme');
INSERT INTO federated.t1 (id, name) values (1, 'server_two, new scheme, second_db.t1');
SELECT * FROM federated.t1;
id	name
1	federated.old2 url
1	server_two, new scheme
1	federated.urldb2t1 -> second_db.t1, url format
1	server_two, new scheme, second_db.t1
INSERT INTO federated.whatever (id, name) values (1, 'server_two, new scheme, whatever, second_db.t1');
SELECT * FROM federated.whatever;
id	name
1	federated.urldb2t1 -> second_db.t1, url format
1	server_two, new scheme, second_db.t1
1	server_two, new scheme, whatever, second_db.t1
drop table federated.t1;
drop server 'server_one';
drop server 'server_two';
@@ -104,6 +169,116 @@ drop table first_db.t1;
drop table second_db.t1;
drop database first_db;
drop database second_db;
create database db_legitimate;
create database db_bogus;
use db_legitimate;
CREATE TABLE db_legitimate.t1 (
`id` int(20) NOT NULL,
`name` varchar(64) NOT NULL default ''
    );
INSERT INTO db_legitimate.t1 VALUES ('1','this is legitimate');
use db_bogus;
CREATE TABLE db_bogus.t1 (
`id` int(20) NOT NULL,
`name` varchar(64) NOT NULL default ''
    )
;
INSERT INTO db_bogus.t1 VALUES ('2','this is bogus');
create server 's1' foreign data wrapper 'mysql' options
(HOST '127.0.0.1',
DATABASE 'db_legitimate',
USER 'root',
PASSWORD '',
PORT SLAVE_PORT,
SOCKET '',
OWNER 'root');
create user guest_select@localhost;
grant select on federated.* to guest_select@localhost;
create user guest_super@localhost;
grant select,SUPER,RELOAD on *.* to guest_super@localhost;
create user guest_usage@localhost;
grant usage on *.* to guest_usage@localhost;
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`name` varchar(64) NOT NULL default ''
    ) ENGINE = FEDERATED CONNECTION = 's1';
select * from federated.t1;
id	name
1	this is legitimate
alter server s1 options (database 'db_bogus');
ERROR 42000: Access denied; you need the SUPER privilege for this operation
flush tables;
select * from federated.t1;
id	name
1	this is legitimate
alter server s1 options (database 'db_bogus');
ERROR 42000: Access denied; you need the SUPER privilege for this operation
flush tables;
select * from federated.t1;
id	name
1	this is legitimate
alter server s1 options (database 'db_bogus');
flush tables;
select * from federated.t1;
id	name
2	this is bogus
drop server if exists 's1';
ERROR 42000: Access denied; you need the SUPER privilege for this operation
create server 's1' foreign data wrapper 'mysql' options
(HOST '127.0.0.1',
DATABASE 'db_legitimate',
USER 'root',
PASSWORD '',
PORT SLAVE_PORT,
SOCKET '',
OWNER 'root');
ERROR 42000: Access denied; you need the SUPER privilege for this operation
drop server 's1';
create server 's1' foreign data wrapper 'mysql' options
(HOST '127.0.0.1',
DATABASE 'db_legitimate',
USER 'root',
PASSWORD '',
PORT SLAVE_PORT,
SOCKET '',
OWNER 'root');
flush tables;
select * from federated.t1;
id	name
1	this is legitimate
drop database db_legitimate;
drop database db_bogus;
drop user guest_super@localhost;
drop user guest_usage@localhost;
drop user guest_select@localhost;
drop table federated.t1;
drop server 's1';
# End of 5.1 tests
use test;
create procedure p1 ()
begin
DECLARE v INT DEFAULT 0;
DECLARE e INT DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET e = e + 1;
WHILE v < 10000 do
CREATE SERVER s
FOREIGN DATA WRAPPER mysql
OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
ALTER SERVER s OPTIONS (USER 'Remote');
DROP SERVER s;
SET v = v + 1;
END WHILE;
SELECT e > 0;
END//
use test;
call p1();
call p1();
e > 0
1
e > 0
1
drop procedure p1;
drop server if exists s;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
+27 −0
Original line number Diff line number Diff line
@@ -280,6 +280,33 @@ a
1
1
drop table t1;
CREATE TABLE t1 (
c1 CHAR(3),
c2 INTEGER,
KEY USING BTREE(c1),
KEY USING BTREE(c2)
) ENGINE= MEMORY;
INSERT INTO t1 VALUES ('ABC',0), ('A',0), ('B',0), ('C',0);
UPDATE t1 SET c2= c2 + 1 WHERE c1 = 'A';
SELECT * FROM t1;
c1	c2
ABC	0
A	1
B	0
C	0
DROP TABLE t1;
CREATE TABLE t1 (
c1 ENUM('1', '2'),
UNIQUE USING BTREE(c1)
) ENGINE= MEMORY DEFAULT CHARSET= utf8;
INSERT INTO t1 VALUES('1'), ('2');
DROP TABLE t1;
CREATE TABLE t1 (
c1 SET('1', '2'),
UNIQUE USING BTREE(c1)
) ENGINE= MEMORY DEFAULT CHARSET= utf8;
INSERT INTO t1 VALUES('1'), ('2');
DROP TABLE t1;
End of 4.1 tests
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
INSERT INTO t1 VALUES(0);
+217 −5
Original line number Diff line number Diff line
@@ -17,6 +17,13 @@ CREATE TABLE first_db.t1 (
    )
  DEFAULT CHARSET=latin1;

DROP TABLE IF EXISTS first_db.t2;
CREATE TABLE first_db.t2 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  DEFAULT CHARSET=latin1;

use second_db;
DROP TABLE IF EXISTS second_db.t1;
CREATE TABLE second_db.t1 (
@@ -25,6 +32,13 @@ CREATE TABLE second_db.t1 (
    )
  DEFAULT CHARSET=latin1;

DROP TABLE IF EXISTS second_db.t2;
CREATE TABLE second_db.t2 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  DEFAULT CHARSET=latin1;

connection master;

drop server if exists 'server_one';
@@ -61,7 +75,7 @@ eval CREATE TABLE federated.old (
  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
  CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/first_db/t1';

INSERT INTO federated.old (id, name) values (1, 'federated.old url');
INSERT INTO federated.old (id, name) values (1, 'federated.old-> first_db.t1, url format');

SELECT * FROM federated.old;

@@ -72,9 +86,32 @@ eval CREATE TABLE federated.old2 (
    `name` varchar(64) NOT NULL default ''
    )
  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
  CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/first_db/t2';

INSERT INTO federated.old2 (id, name) values (1, 'federated.old2-> first_db.t2, url format');
SELECT * FROM federated.old2;

DROP TABLE IF EXISTS federated.urldb2t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.urldb2t1 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
  CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/second_db/t1';
INSERT INTO federated.urldb2t1 (id, name) values (1, 'federated.urldb2t1 -> second_db.t1, url format');
SELECT * FROM federated.urldb2t1;

INSERT INTO federated.old2 (id, name) values (1, 'federated.old2 url');
DROP TABLE IF EXISTS federated.urldb2t2;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.urldb2t2 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
  CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/second_db/t2';
INSERT INTO federated.urldb2t2 (id, name) values (1, 'federated.urldb2t2 -> second_db.t2, url format');
SELECT * FROM federated.urldb2t2;

DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
@@ -84,17 +121,30 @@ CREATE TABLE federated.t1 (
  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
  CONNECTION='server_one';

INSERT INTO federated.t1 (id, name) values (1, 'server_one, new scheme');
INSERT INTO federated.t1 (id, name) values (1, 'server_one, new scheme, first_db.t1');

SELECT * FROM federated.t1;

DROP TABLE IF EXISTS federated.whatever;
CREATE TABLE federated.whatever (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
  CONNECTION='server_one/t1';
INSERT INTO federated.whatever (id, name) values (1, 'server_one, new scheme, whatever, first_db.t1');
SELECT * FROM federated.whatever;

ALTER SERVER 'server_one' options(DATABASE 'second_db');

flush tables;
# FLUSH TABLES is now unneccessary

INSERT INTO federated.t1 (id, name) values (1, 'server_two, new scheme');
INSERT INTO federated.t1 (id, name) values (1, 'server_two, new scheme, second_db.t1');
SELECT * FROM federated.t1;

INSERT INTO federated.whatever (id, name) values (1, 'server_two, new scheme, whatever, second_db.t1');
SELECT * FROM federated.whatever;

drop table federated.t1;

drop server 'server_one';
@@ -107,4 +157,166 @@ drop table second_db.t1;
drop database first_db;
drop database second_db;

#
# Bug#25671 - CREATE/DROP/ALTER SERVER should require privileges
#
# Changes to SERVER declarations should require SUPER privilege.
# Based upon test case by Giuseppe Maxia

create database db_legitimate;
create database db_bogus;

use db_legitimate;
CREATE TABLE db_legitimate.t1 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    );
INSERT INTO db_legitimate.t1 VALUES ('1','this is legitimate');

use db_bogus;
CREATE TABLE db_bogus.t1 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  ;
INSERT INTO db_bogus.t1 VALUES ('2','this is bogus');

connection master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval create server 's1' foreign data wrapper 'mysql' options
  (HOST '127.0.0.1',
  DATABASE 'db_legitimate',
  USER 'root',
  PASSWORD '',
  PORT $SLAVE_MYPORT,
  SOCKET '',
  OWNER 'root');

create user guest_select@localhost;
grant select on federated.* to guest_select@localhost;

create user guest_super@localhost;
grant select,SUPER,RELOAD on *.* to guest_super@localhost;

create user guest_usage@localhost;
grant usage on *.* to guest_usage@localhost;

CREATE TABLE federated.t1 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    ) ENGINE = FEDERATED CONNECTION = 's1';

select * from federated.t1;

connect (conn_select,127.0.0.1,guest_select,,federated,$MASTER_MYPORT);
connect (conn_usage,127.0.0.1,guest_usage,,,$MASTER_MYPORT);
connect (conn_super,127.0.0.1,guest_super,,,$MASTER_MYPORT);

connection conn_select;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
alter server s1 options (database 'db_bogus');

connection master;
flush tables;
select * from federated.t1;

connection conn_usage;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
alter server s1 options (database 'db_bogus');

connection master;
flush tables;
select * from federated.t1;

connection conn_super;
alter server s1 options (database 'db_bogus');

connection master;
flush tables;
select * from federated.t1;

connection conn_select;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
drop server if exists 's1';
--replace_result $SLAVE_MYPORT SLAVE_PORT
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
eval create server 's1' foreign data wrapper 'mysql' options
  (HOST '127.0.0.1',
  DATABASE 'db_legitimate',
  USER 'root',
  PASSWORD '',
  PORT $SLAVE_MYPORT,
  SOCKET '',
  OWNER 'root');

connection conn_super;
drop server 's1';
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval create server 's1' foreign data wrapper 'mysql' options
  (HOST '127.0.0.1',
  DATABASE 'db_legitimate',
  USER 'root',
  PASSWORD '',
  PORT $SLAVE_MYPORT,
  SOCKET '',
  OWNER 'root');

connection master;
flush tables;
select * from federated.t1;

# clean up test
connection slave;
drop database db_legitimate;
drop database db_bogus;

disconnect conn_select;
disconnect conn_usage;
disconnect conn_super;

connection master;
drop user guest_super@localhost;
drop user guest_usage@localhost;
drop user guest_select@localhost;
drop table federated.t1;
drop server 's1';


--echo # End of 5.1 tests


#
# Bug#25721 - deadlock with ALTER/CREATE SERVER
#
connect (other,localhost,root,,);
connection master;
use test;
delimiter //;
create procedure p1 ()
begin
  DECLARE v INT DEFAULT 0;
  DECLARE e INT DEFAULT 0;
  DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET e = e + 1;
  WHILE v < 10000 do
    CREATE SERVER s
      FOREIGN DATA WRAPPER mysql
      OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
    ALTER SERVER s OPTIONS (USER 'Remote');
	DROP SERVER s;
    SET v = v + 1;
  END WHILE;
  SELECT e > 0;
END//
delimiter ;//
connection other;
use test;
send call p1();
connection master;
call p1();
connection other;
reap;
drop procedure p1;
drop server if exists s;


source include/federated_cleanup.inc;
+31 −0
Original line number Diff line number Diff line
@@ -182,6 +182,37 @@ delete from t1 where a >= 2;
select a from t1 order by a;
drop table t1;

#
# Bug#26996 - Update of a Field in a Memory Table ends with wrong result
#
CREATE TABLE t1 (
  c1 CHAR(3),
  c2 INTEGER,
  KEY USING BTREE(c1),
  KEY USING BTREE(c2)
) ENGINE= MEMORY;
INSERT INTO t1 VALUES ('ABC',0), ('A',0), ('B',0), ('C',0);
UPDATE t1 SET c2= c2 + 1 WHERE c1 = 'A';
SELECT * FROM t1;
DROP TABLE t1;

#
# Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE
#             causes incorrect duplicate entries
#
CREATE TABLE t1 (
  c1 ENUM('1', '2'),
  UNIQUE USING BTREE(c1)
) ENGINE= MEMORY DEFAULT CHARSET= utf8;
INSERT INTO t1 VALUES('1'), ('2');
DROP TABLE t1;
CREATE TABLE t1 (
  c1 SET('1', '2'),
  UNIQUE USING BTREE(c1)
) ENGINE= MEMORY DEFAULT CHARSET= utf8;
INSERT INTO t1 VALUES('1'), ('2');
DROP TABLE t1;

--echo End of 4.1 tests

#
+4 −4
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
    errno=0;					/* Linux doesn't reset this */
#endif
#ifndef HAVE_PREAD
    off_t old_offset;
    os_off_t old_offset;

    pthread_mutex_lock(&my_file_info[Filedes].mutex);
    /*
@@ -45,7 +45,7 @@ uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
      before seeking to the given offset
    */

    error= (old_offset= (off_t)lseek(Filedes, 0L, MY_SEEK_CUR)) == -1L ||
    error= (old_offset= lseek(Filedes, 0L, MY_SEEK_CUR)) == -1L ||
           lseek(Filedes, offset, MY_SEEK_SET) == -1L;

    if (!error)                                 /* Seek was successful */
@@ -116,7 +116,7 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset,
  {
#ifndef HAVE_PREAD
    int error= 0;
    off_t old_offset;
    os_off_t old_offset;
    writenbytes= (uint) -1;
    pthread_mutex_lock(&my_file_info[Filedes].mutex);

@@ -124,7 +124,7 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset,
      As we cannot change the file pointer, we save the old position,
      before seeking to the given offset
    */
    error= ((old_offset= (off_t)lseek(Filedes, 0L, MY_SEEK_CUR)) == -1L ||
    error= ((old_offset= lseek(Filedes, 0L, MY_SEEK_CUR)) == -1L ||
            lseek(Filedes, offset, MY_SEEK_SET) == -1L);

    if (!error)                                 /* Seek was successful */
Loading