Commit 3e399043 authored by unknown's avatar unknown
Browse files

Merge bodhi.local:/opt/local/work/mysql-4.1-4968

into  bodhi.local:/opt/local/work/mysql-5.0-4968-pull-from-4.1


sql/sql_insert.cc:
  Auto merged
mysql-test/r/ps.result:
  Manual merge.
mysql-test/t/ps.test:
  Manual merge.
sql/mysql_priv.h:
  Manual merge.
sql/sql_class.h:
  Manual merge.
sql/sql_lex.cc:
  Manual merge.
sql/sql_lex.h:
  Manual merge.
sql/sql_list.h:
  Manual merge.
sql/sql_parse.cc:
  Manual merge.
sql/sql_show.cc:
  Manual merge.
sql/sql_table.cc:
  Manual merge.
sql/sql_yacc.yy:
  Manual merge.
parents fe84b016 e47ded81
Loading
Loading
Loading
Loading
+291 −0
Original line number Diff line number Diff line
@@ -1055,6 +1055,297 @@ EXECUTE stmt USING @a;
0	0
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
ERROR HY000: Unknown error
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	0
set global max_prepared_stmt_count=1;
prepare stmt from "select 1";
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	1
prepare stmt1 from "select 1";
ERROR HY000: Unknown error
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	1
deallocate prepare stmt;
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	0
prepare stmt from "select 1";
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	1
prepare stmt from "select 2";
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	1
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	1
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
1
set global max_prepared_stmt_count=0;
prepare stmt from "select 1";
ERROR HY000: Unknown error
execute stmt;
ERROR HY000: Unknown prepared statement handler (stmt) given to EXECUTE
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	0
prepare stmt from "select 1";
ERROR HY000: Unknown error
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	0
set global max_prepared_stmt_count=3;
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
3
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	0
prepare stmt from "select 1";
prepare stmt from "select 2";
prepare stmt1 from "select 3";
prepare stmt2 from "select 4";
ERROR HY000: Unknown error
prepare stmt2 from "select 4";
ERROR HY000: Unknown error
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
3
show status like 'prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	3
deallocate prepare stmt;
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
drop table if exists t1;
create temporary table if not exists t1 (a1 int);
prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
drop temporary table t1;
create temporary table if not exists t1 (a1 int);
execute stmt;
drop temporary table t1;
create temporary table if not exists t1 (a1 int);
execute stmt;
drop temporary table t1;
create temporary table if not exists t1 (a1 int);
execute stmt;
drop temporary table t1;
deallocate prepare stmt;
CREATE TABLE t1(
ID int(10) unsigned NOT NULL auto_increment,
Member_ID varchar(15) NOT NULL default '',
Action varchar(12) NOT NULL,
Action_Date datetime NOT NULL,
Track varchar(15) default NULL,
User varchar(12) default NULL,
Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
PRIMARY KEY (ID),
KEY Action (Action),
KEY Action_Date (Action_Date)
);
INSERT INTO t1(Member_ID, Action, Action_Date, Track) VALUES
('111111', 'Disenrolled', '2006-03-01', 'CAD' ),
('111111', 'Enrolled', '2006-03-01', 'CAD' ),
('111111', 'Disenrolled', '2006-07-03', 'CAD' ),
('222222', 'Enrolled', '2006-03-07', 'CAD' ),
('222222', 'Enrolled', '2006-03-07', 'CHF' ),
('222222', 'Disenrolled', '2006-08-02', 'CHF' ),
('333333', 'Enrolled', '2006-03-01', 'CAD' ),
('333333', 'Disenrolled', '2006-03-01', 'CAD' ),
('444444', 'Enrolled', '2006-03-01', 'CAD' ),
('555555', 'Disenrolled', '2006-03-01', 'CAD' ),
('555555', 'Enrolled', '2006-07-21', 'CAD' ),
('555555', 'Disenrolled', '2006-03-01', 'CHF' ),
('666666', 'Enrolled', '2006-02-09', 'CAD' ),
('666666', 'Enrolled', '2006-05-12', 'CHF' ),
('666666', 'Disenrolled', '2006-06-01', 'CAD' );
PREPARE STMT FROM
"SELECT GROUP_CONCAT(Track SEPARATOR ', ') FROM t1
  WHERE Member_ID=? AND Action='Enrolled' AND
        (Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t1
                                  WHERE Member_ID=?
                                    GROUP BY Track 
                                      HAVING Track>='CAD' AND
                                             MAX(Action_Date)>'2006-03-01')";
SET @id='111111';
EXECUTE STMT USING @id,@id;
GROUP_CONCAT(Track SEPARATOR ', ')
NULL
SET @id='222222';
EXECUTE STMT USING @id,@id;
GROUP_CONCAT(Track SEPARATOR ', ')
CAD
DEALLOCATE PREPARE STMT;
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT, INDEX(i));
INSERT INTO t1 VALUES (1);
PREPARE stmt FROM "SELECT (COUNT(i) = 1), COUNT(i) FROM t1 WHERE i = ?";
SET @a = 0;
EXECUTE stmt USING @a;
(COUNT(i) = 1)	COUNT(i)
0	0
SET @a = 1;
EXECUTE stmt USING @a;
(COUNT(i) = 1)	COUNT(i)
1	1
SET @a = 0;
EXECUTE stmt USING @a;
(COUNT(i) = 1)	COUNT(i)
0	0
PREPARE stmt FROM "SELECT (AVG(i) = 1), AVG(i) FROM t1 WHERE i = ?";
SET @a = 0;
EXECUTE stmt USING @a;
(AVG(i) = 1)	AVG(i)
NULL	NULL
SET @a = 1;
EXECUTE stmt USING @a;
(AVG(i) = 1)	AVG(i)
1	1.0000
SET @a = 0;
EXECUTE stmt USING @a;
(AVG(i) = 1)	AVG(i)
NULL	NULL
PREPARE stmt FROM "SELECT (VARIANCE(i) = 1), VARIANCE(i) FROM t1 WHERE i = ?";
SET @a = 0;
EXECUTE stmt USING @a;
(VARIANCE(i) = 1)	VARIANCE(i)
NULL	NULL
SET @a = 1;
EXECUTE stmt USING @a;
(VARIANCE(i) = 1)	VARIANCE(i)
0	0.0000
SET @a = 0;
EXECUTE stmt USING @a;
(VARIANCE(i) = 1)	VARIANCE(i)
NULL	NULL
PREPARE stmt FROM "SELECT (STDDEV(i) = 1), STDDEV(i) FROM t1 WHERE i = ?";
SET @a = 0;
EXECUTE stmt USING @a;
(STDDEV(i) = 1)	STDDEV(i)
NULL	NULL
SET @a = 1;
EXECUTE stmt USING @a;
(STDDEV(i) = 1)	STDDEV(i)
0	0.0000
SET @a = 0;
EXECUTE stmt USING @a;
(STDDEV(i) = 1)	STDDEV(i)
NULL	NULL
PREPARE stmt FROM "SELECT (BIT_OR(i) = 1), BIT_OR(i) FROM t1 WHERE i = ?";
SET @a = 0;
EXECUTE stmt USING @a;
(BIT_OR(i) = 1)	BIT_OR(i)
0	0
SET @a = 1;
EXECUTE stmt USING @a;
(BIT_OR(i) = 1)	BIT_OR(i)
1	1
SET @a = 0;
EXECUTE stmt USING @a;
(BIT_OR(i) = 1)	BIT_OR(i)
0	0
PREPARE stmt FROM "SELECT (BIT_AND(i) = 1), BIT_AND(i) FROM t1 WHERE i = ?";
SET @a = 0;
EXECUTE stmt USING @a;
(BIT_AND(i) = 1)	BIT_AND(i)
0	18446744073709551615
SET @a = 1;
EXECUTE stmt USING @a;
(BIT_AND(i) = 1)	BIT_AND(i)
1	1
SET @a = 0;
EXECUTE stmt USING @a;
(BIT_AND(i) = 1)	BIT_AND(i)
0	18446744073709551615
PREPARE stmt FROM "SELECT (BIT_XOR(i) = 1), BIT_XOR(i) FROM t1 WHERE i = ?";
SET @a = 0;
EXECUTE stmt USING @a;
(BIT_XOR(i) = 1)	BIT_XOR(i)
0	0
SET @a = 1;
EXECUTE stmt USING @a;
(BIT_XOR(i) = 1)	BIT_XOR(i)
1	1
SET @a = 0;
EXECUTE stmt USING @a;
(BIT_XOR(i) = 1)	BIT_XOR(i)
0	0
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (i INT);
PREPARE st_19182
FROM "CREATE TABLE t2 (i INT, j INT, KEY (i), KEY(j)) SELECT i FROM t1";
EXECUTE st_19182;
DESC t2;
Field	Type	Null	Key	Default	Extra
j	int(11)	YES	MUL	NULL	
i	int(11)	YES	MUL	NULL	
DROP TABLE t2;
EXECUTE st_19182;
DESC t2;
Field	Type	Null	Key	Default	Extra
j	int(11)	YES	MUL	NULL	
i	int(11)	YES	MUL	NULL	
DEALLOCATE PREPARE st_19182;
DROP TABLE t2, t1;
drop database if exists mysqltest;
drop table if exists t1, t2;
create database mysqltest character set utf8;
prepare stmt1 from "create table mysqltest.t1 (c char(10))";
prepare stmt2 from "create table mysqltest.t2 select 'test'";
execute stmt1;
execute stmt2;
show create table mysqltest.t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c` char(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
show create table mysqltest.t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `test` char(4) character set latin1 NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=utf8
drop table mysqltest.t1;
drop table mysqltest.t2;
alter database mysqltest character set latin1;
execute stmt1;
execute stmt2;
show create table mysqltest.t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c` char(10) character set utf8 default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show create table mysqltest.t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `test` char(4) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop database mysqltest;
deallocate prepare stmt1;
deallocate prepare stmt2;
execute stmt;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c` char(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/'
drop table t1;
execute stmt;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c` char(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/'
drop table t1;
deallocate prepare stmt;
End of 4.1 tests.
create table t1 (a varchar(20));
insert into t1 values ('foo');
+71 −1
Original line number Diff line number Diff line
@@ -1106,10 +1106,80 @@ EXECUTE stmt USING @a;
DEALLOCATE PREPARE stmt;
DROP TABLE t1;

#
# Bug#19182: CREATE TABLE bar (m INT) SELECT n FROM foo; doesn't work
# from stored procedure.
#
# The cause of a bug was that cached LEX::create_list was modified,
# and then together with LEX::key_list was reset.
#
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings

--echo End of 4.1 tests.
CREATE TABLE t1 (i INT);

PREPARE st_19182
FROM "CREATE TABLE t2 (i INT, j INT, KEY (i), KEY(j)) SELECT i FROM t1";

EXECUTE st_19182;
DESC t2;

DROP TABLE t2;

# Check that on second execution we don't loose 'j' column and the keys
# on 'i' and 'j' columns.
EXECUTE st_19182;
DESC t2;

DEALLOCATE PREPARE st_19182;
DROP TABLE t2, t1;

#
# Bug #22060 "ALTER TABLE x AUTO_INCREMENT=y in SP crashes server"
#
# Code which implemented CREATE/ALTER TABLE and CREATE DATABASE
# statement modified HA_CREATE_INFO structure in LEX, making these
# statements PS/SP-unsafe (their re-execution might have resulted
# in incorrect results).
#
--disable_warnings
drop database if exists mysqltest;
drop table if exists t1, t2;
--enable_warnings
# CREATE TABLE and CREATE TABLE ... SELECT
create database mysqltest character set utf8;
prepare stmt1 from "create table mysqltest.t1 (c char(10))";
prepare stmt2 from "create table mysqltest.t2 select 'test'";
execute stmt1;
execute stmt2;
show create table mysqltest.t1;
show create table mysqltest.t2;
drop table mysqltest.t1;
drop table mysqltest.t2;
alter database mysqltest character set latin1;
execute stmt1;
execute stmt2;
show create table mysqltest.t1;
show create table mysqltest.t2;
drop database mysqltest;
deallocate prepare stmt1;
deallocate prepare stmt2;
# CREATE TABLE with DATA DIRECTORY option
--disable_query_log
eval prepare stmt from "create table t1 (c char(10)) data directory='$MYSQLTEST_VARDIR/tmp'";
--enable_query_log
execute stmt;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
show create table t1;
drop table t1;
execute stmt;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
show create table t1;
drop table t1;
deallocate prepare stmt;

--echo End of 4.1 tests.

############################# 5.0 tests start ################################
#
+6 −10
Original line number Diff line number Diff line
@@ -774,17 +774,15 @@ int prepare_create_field(create_field *sql_field,
			 uint table_flags);
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
                        HA_CREATE_INFO *create_info,
                        List<create_field> &fields, List<Key> &keys,
                        Alter_info *alter_info,
                        bool tmp_table, uint select_field_count);

bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
                       HA_CREATE_INFO *create_info,
                       TABLE_LIST *table_list,
                       List<create_field> &fields,
                       List<Key> &keys,
                       uint order_num, ORDER *order, bool ignore,
                       ALTER_INFO *alter_info, bool do_send_ok);
bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool do_send_ok);
                       Alter_info *alter_info,
                       uint order_num, ORDER *order, bool ignore);
bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list);
bool mysql_create_like_table(THD *thd, TABLE_LIST *table,
                             HA_CREATE_INFO *create_info,
                             Table_ident *src_table);
@@ -793,9 +791,6 @@ bool mysql_rename_table(enum db_type base,
			const char * old_name,
			const char *new_db,
			const char * new_name);
bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys);
bool mysql_drop_index(THD *thd, TABLE_LIST *table_list,
                      ALTER_INFO *alter_info);
bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
                          Item **conds, uint order_num, ORDER *order);
int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
@@ -897,7 +892,8 @@ int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
bool mysqld_show_create_db(THD *thd, char *dbname,
                           const HA_CREATE_INFO *create);

void mysqld_list_processes(THD *thd,const char *user,bool verbose);
int mysqld_show_status(THD *thd);
+11 −10
Original line number Diff line number Diff line
@@ -1840,19 +1840,20 @@ class select_insert :public select_result_interceptor {
class select_create: public select_insert {
  ORDER *group;
  TABLE_LIST *create_table;
  List<create_field> *extra_fields;
  List<Key> *keys;
  HA_CREATE_INFO *create_info;
  Alter_info *alter_info;
  MYSQL_LOCK *lock;
  Field **field;
public:
  select_create(TABLE_LIST *table,
		 HA_CREATE_INFO *create_info_par,
		 List<create_field> &fields_par,
		 List<Key> &keys_par,
		 List<Item> &select_fields,enum_duplicates duplic, bool ignore)
    :select_insert (NULL, NULL, &select_fields, 0, 0, duplic, ignore), create_table(table),
    extra_fields(&fields_par),keys(&keys_par), create_info(create_info_par),
                HA_CREATE_INFO *create_info_arg,
                Alter_info *alter_info_arg,
                List<Item> &select_fields,
                enum_duplicates duplic, bool ignore)
    :select_insert(NULL, NULL, &select_fields, 0, 0, duplic, ignore),
    create_table(table),
    create_info(create_info_arg),
    alter_info(alter_info_arg),
    lock(0)
  {}
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
+1 −1
Original line number Diff line number Diff line
@@ -2764,7 +2764,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)

  unit= u;
  table= create_table_from_items(thd, create_info, create_table,
				 extra_fields, keys, &values, &lock);
                                 alter_info, &values, &lock);
  if (!table)
    DBUG_RETURN(-1);				// abort() deletes table

Loading