Merge jhe@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb-bj

into  dev3-240.dev.cn.tlan:/home/justin.he/mysql/mysql-5.0/mysql-5.0-ndb-bj
This commit is contained in:
Justin.He/justin.he@dev3-240.dev.cn.tlan 2007-05-11 18:02:57 +08:00
commit bc4df94e3f
99 changed files with 4599 additions and 3190 deletions

View file

@ -26,6 +26,10 @@ ADD_DEFINITIONS(-D WITH_MYISAM_STORAGE_ENGINE)
ADD_DEFINITIONS(-D CMAKE_BUILD)
ADD_DEFINITIONS(-D HAVE_YASSL)
# Set debug options
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DFORCE_INIT_OF_VARS")
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisam_plugin")
@ -116,6 +120,9 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG
${CMAKE_CXX_FLAGS_DEBUG})
# generate map files
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS")
# remove support for Exception handling
STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})

View file

@ -64,13 +64,13 @@ link_sources:
for f in $(sql_src) ; do \
rm -f $$f; \
@LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
done; \
for f in $(strings_src) ; do \
rm -f $(srcdir)/$$f; \
@LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \
done; \
rm -f $(srcdir)/my_user.c; \
@LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c;
done; \
for f in $(strings_src) ; do \
rm -f $(srcdir)/$$f; \
@LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \
done; \
rm -f $(srcdir)/my_user.c; \
@LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c;
# Don't update the files from bitkeeper

View file

@ -1489,8 +1489,15 @@ static uint dump_routines_for_db(char *db)
routine body of other routines that are not the creator of!
*/
DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d",
routine_name, row[2], (int) strlen(row[2])));
if (strlen(row[2]))
routine_name, row[2] ? row[2] : "(null)",
row[2] ? (int) strlen(row[2]) : 0));
if (row[2] == NULL)
{
fprintf(sql_file, "\n-- insufficient privileges to %s\n", query_buff);
fprintf(sql_file, "-- does %s have permissions on mysql.proc?\n\n", current_user);
maybe_die(EX_MYSQLERR,"%s has insufficent privileges to %s!", current_user, query_buff);
}
else if (strlen(row[2]))
{
char *query_str= NULL;
char *definer_begin;
@ -1540,7 +1547,7 @@ static uint dump_routines_for_db(char *db)
/*
we need to change sql_mode only for the CREATE
PROCEDURE/FUNCTION otherwise we may need to re-quote routine_name
*/;
*/
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\"*/;;\n",
row[1] /* sql_mode */);
fprintf(sql_file, "/*!50003 %s */;;\n",

View file

@ -33,7 +33,20 @@ const char *default_dbug_option="d:t:o,/tmp/my_print_defaults.trace";
static struct my_option my_long_options[] =
{
{"config-file", 'c', "The config file to be used.",
/*
NB: --config-file is troublesome, because get_defaults_options() doesn't
know about it, but we pretend --config-file is like --defaults-file. In
fact they behave differently: see the comments at the top of
mysys/default.c for how --defaults-file should behave.
This --config-file option behaves as:
- If it has a directory name part (absolute or relative), then only this
file is read; no error is given if the file doesn't exist
- If the file has no directory name part, the standard locations are
searched for a file of this name (and standard filename extensions are
added if the file has no extension)
*/
{"config-file", 'c', "Deprecated, please use --defaults-file instead. Name of config file to read; if no extension is given, default extension (e.g., .ini or .cnf) will be added",
(gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
#ifdef DBUG_OFF
@ -43,11 +56,11 @@ static struct my_option my_long_options[] =
{"debug", '#', "Output debug log", (gptr*) &default_dbug_option,
(gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"defaults-file", 'c', "Synonym for --config-file.",
{"defaults-file", 'c', "Like --config-file, except: if first option, then read this file only, do not read global or per-user config files; should be the first option",
(gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"defaults-extra-file", 'e',
"Read this file after the global /etc config file and before the config file in the users home directory.",
"Read this file after the global config file and before the config file in the users home directory; should be the first option",
(gptr*) &my_defaults_extra_file, (gptr*) &my_defaults_extra_file, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"defaults-group-suffix", 'g',
@ -55,7 +68,7 @@ static struct my_option my_long_options[] =
(gptr*) &my_defaults_group_suffix, (gptr*) &my_defaults_group_suffix,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"extra-file", 'e',
"Synonym for --defaults-extra-file.",
"Deprecated. Synonym for --defaults-extra-file.",
(gptr*) &my_defaults_extra_file,
(gptr*) &my_defaults_extra_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@ -86,7 +99,7 @@ static void usage(my_bool version)
my_print_help(my_long_options);
my_print_default_files(config_file);
my_print_variables(my_long_options);
printf("\nExample usage:\n%s --config-file=my client mysql\n", my_progname);
printf("\nExample usage:\n%s --defaults-file=example.cnf client mysql\n", my_progname);
}
#include <help_end.h>

View file

@ -784,13 +784,20 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define SSIZE_MAX ((~((size_t) 0)) / 2)
#endif
#ifndef HAVE_FINITE
#define finite(x) (1.0 / fabs(x) > 0.0)
#endif
#ifndef HAVE_ISNAN
#define isnan(x) ((x) != (x))
#endif
#if !defined(HAVE_ISINF)
/* The configure check for "isinf with math.h" has failed */
#ifdef isinf
#undef isinf
#endif
/* Define isinf to never say that X is infinite */
#define isinf(X) 0
#define isinf(X) (!finite(X) && !isnan(X))
#endif
/* Define missing math constants. */

View file

@ -127,11 +127,11 @@ link_sources:
for f in $(sqlsources); do \
rm -f $$f; \
if test -e $(top_srcdir)/sql/$$f ; \
then \
then \
@LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
else \
else \
@LN_CP_F@ $(top_builddir)/sql/$$f $$f; \
fi ; \
fi ; \
done; \
for f in $(libmysqlsources); do \
rm -f $$f; \

View file

@ -0,0 +1,4 @@
--require r/lowercase1.require
--disable_query_log
show variables like 'lower_case_table_names';
--enable_query_log

View file

@ -1171,7 +1171,7 @@ execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
######## SELECT .. WHERE column(date/time/..)=value(DATETIME/LONGBLOB) ########
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and
@ -1180,7 +1180,7 @@ select 'true' as found from t9
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
and c17= @arg00 ;
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and

View file

@ -238,7 +238,7 @@ sub mtr_report_stats ($) {
}
if (!$::opt_extern)
{
print "The servers where restarted $tot_restarts times\n";
print "The servers were restarted $tot_restarts times\n";
}
if ( $::opt_timer )
@ -357,7 +357,7 @@ sub mtr_report_stats ($) {
if ( $tot_failed != 0 || $found_problems)
{
mtr_error("there where failing test cases");
mtr_error("there were failing test cases");
}
}

View file

@ -860,3 +860,27 @@ ALTER TABLE t1 ADD d INT;
ALTER TABLE t1 ADD KEY (d(20));
ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys
DROP TABLE t1;
create table t1(id int(8) primary key auto_increment) engine=heap;
insert into t1 values (null);
insert into t1 values (null);
select * from t1;
id
1
2
alter table t1 auto_increment = 50;
alter table t1 engine = myisam;
insert into t1 values (null);
select * from t1;
id
1
2
50
alter table t1 engine = heap;
insert into t1 values (null);
select * from t1;
id
1
2
50
51
drop table t1;

View file

@ -633,7 +633,7 @@ EXPLAIN SELECT (SELECT DISTINCT ADDDATE(a,1) FROM t1
WHERE ADDDATE(a,1) = '2002-08-03');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where; Using temporary
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
CREATE TABLE t2 (a CHAR(5) CHARACTER SET latin1 COLLATE latin1_general_ci);
INSERT INTO t2 VALUES (0xf6);
INSERT INTO t2 VALUES ('oe');

View file

@ -143,9 +143,6 @@ select format(col2,6) from t1 where col1=7;
format(col2,6)
1,234,567,890,123,456.123450
drop table t1;
select round(150, 2);
round(150, 2)
150.00
select ceil(0.09);
ceil(0.09)
1
@ -156,11 +153,11 @@ create table t1 select round(1, 6);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`round(1, 6)` decimal(7,6) NOT NULL default '0.000000'
`round(1, 6)` int(1) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
round(1, 6)
1.000000
1
drop table t1;
select abs(-2) * -2;
abs(-2) * -2
@ -238,3 +235,91 @@ format(t2.f2-t2.f1+1,0)
10,000
drop table t1, t2;
set names default;
select cast(-2 as unsigned), 18446744073709551614, -2;
cast(-2 as unsigned) 18446744073709551614 -2
18446744073709551614 18446744073709551614 -2
select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2);
abs(cast(-2 as unsigned)) abs(18446744073709551614) abs(-2)
18446744073709551614 18446744073709551614 2
select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2);
ceiling(cast(-2 as unsigned)) ceiling(18446744073709551614) ceiling(-2)
18446744073709551614 18446744073709551614 -2
select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2);
floor(cast(-2 as unsigned)) floor(18446744073709551614) floor(-2)
18446744073709551614 18446744073709551614 -2
select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2);
format(cast(-2 as unsigned), 2) format(18446744073709551614, 2) format(-2, 2)
18,446,744,073,709,551,614.00 18,446,744,073,709,551,614.00 -2.00
select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2);
sqrt(cast(-2 as unsigned)) sqrt(18446744073709551614) sqrt(-2)
4294967296 4294967296 NULL
select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1);
round(cast(-2 as unsigned), 1) round(18446744073709551614, 1) round(-2, 1)
18446744073709551614 18446744073709551614 -2
select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2);
round(4, cast(-2 as unsigned)) round(4, 18446744073709551614) round(4, -2)
4 4 0
select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1);
truncate(cast(-2 as unsigned), 1) truncate(18446744073709551614, 1) truncate(-2, 1)
18446744073709551614 18446744073709551614 -2
select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2);
truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, -2)
4 4 0
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
round(10000000000000000000, -19) truncate(10000000000000000000, -19)
10000000000000000000 10000000000000000000
select round(1e0, -309), truncate(1e0, -309);
round(1e0, -309) truncate(1e0, -309)
0 0
select round(1e1,308), truncate(1e1, 308);
round(1e1,308) truncate(1e1, 308)
10 10
select round(1e1, 2147483648), truncate(1e1, 2147483648);
round(1e1, 2147483648) truncate(1e1, 2147483648)
10 10
select round(1.1e1, 4294967295), truncate(1.1e1, 4294967295);
round(1.1e1, 4294967295) truncate(1.1e1, 4294967295)
11 11
select round(1.12e1, 4294967296), truncate(1.12e1, 4294967296);
round(1.12e1, 4294967296) truncate(1.12e1, 4294967296)
11.2 11.2
select round(1.5, 2147483640), truncate(1.5, 2147483640);
round(1.5, 2147483640) truncate(1.5, 2147483640)
1.500000000000000000000000000000 1.500000000000000000000000000000
select round(1.5, -2147483649), round(1.5, 2147483648);
round(1.5, -2147483649) round(1.5, 2147483648)
0 1.500000000000000000000000000000
select truncate(1.5, -2147483649), truncate(1.5, 2147483648);
truncate(1.5, -2147483649) truncate(1.5, 2147483648)
0 1.500000000000000000000000000000
select round(1.5, -4294967296), round(1.5, 4294967296);
round(1.5, -4294967296) round(1.5, 4294967296)
0 1.500000000000000000000000000000
select truncate(1.5, -4294967296), truncate(1.5, 4294967296);
truncate(1.5, -4294967296) truncate(1.5, 4294967296)
0 1.500000000000000000000000000000
select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808);
round(1.5, -9223372036854775808) round(1.5, 9223372036854775808)
0 1.500000000000000000000000000000
select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808);
truncate(1.5, -9223372036854775808) truncate(1.5, 9223372036854775808)
0 1.500000000000000000000000000000
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615);
round(1.5, 18446744073709551615) truncate(1.5, 18446744073709551615)
1.500000000000000000000000000000 1.500000000000000000000000000000
select round(18446744073709551614, -1), truncate(18446744073709551614, -1);
round(18446744073709551614, -1) truncate(18446744073709551614, -1)
18446744073709551610 18446744073709551610
select round(4, -4294967200), truncate(4, -4294967200);
round(4, -4294967200) truncate(4, -4294967200)
0 0
select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3);
mod(cast(-2 as unsigned), 3) mod(18446744073709551614, 3) mod(-2, 3)
2 2 -2
select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2);
mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2)
5 5 1
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5)
2.1359870359209e+96 2.1359870359209e+96 -32
End of 5.0 tests

View file

@ -1035,3 +1035,15 @@ HAVING SUM(t1_inner.b)+t1_outer.b > 5);
ERROR 42000: 'test.t1_outer.b' isn't in GROUP BY
DROP TABLE t1;
SET SQL_MODE = '';
SET SQL_MODE = 'ONLY_FULL_GROUP_BY';
create table t1(f1 int, f2 int);
select * from t1 group by f1;
ERROR 42000: 'test.t1.f2' isn't in GROUP BY
select * from t1 group by f2;
ERROR 42000: 'test.t1.f1' isn't in GROUP BY
select * from t1 group by f1, f2;
f1 f2
select t1.f1,t.* from t1, t1 t group by 1;
ERROR 42000: 'test.t.f1' isn't in GROUP BY
drop table t1;
SET SQL_MODE = '';

View file

@ -111,6 +111,39 @@ c1
Before and after comparison
0
drop table t1;
CREATE TABLE t1(c1 TEXT, UNIQUE (c1(1)), cnt INT DEFAULT 1)
ENGINE=INNODB CHARACTER SET UTF8;
INSERT INTO t1 (c1) VALUES ('1a');
SELECT * FROM t1;
c1 cnt
1a 1
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
SELECT * FROM t1;
c1 cnt
1a 2
DROP TABLE t1;
CREATE TABLE t1(c1 VARCHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
ENGINE=INNODB CHARACTER SET UTF8;
INSERT INTO t1 (c1) VALUES ('1a');
SELECT * FROM t1;
c1 cnt
1a 1
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
SELECT * FROM t1;
c1 cnt
1a 2
DROP TABLE t1;
CREATE TABLE t1(c1 CHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
ENGINE=INNODB CHARACTER SET UTF8;
INSERT INTO t1 (c1) VALUES ('1a');
SELECT * FROM t1;
c1 cnt
1a 1
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
SELECT * FROM t1;
c1 cnt
1a 2
DROP TABLE t1;
End of 4.1 tests
create table t1m (a int) engine=myisam;
create table t1i (a int) engine=innodb;
@ -472,4 +505,43 @@ tes 1234
drop table test;
set global query_cache_type=@save_qcache_type;
set global query_cache_size=@save_qcache_size;
create table t1(
id int auto_increment,
c char(1) not null,
counter int not null default 1,
primary key (id),
unique key (c)
) engine=innodb;
insert into t1 (id, c) values
(NULL, 'a'),
(NULL, 'a')
on duplicate key update id = values(id), counter = counter + 1;
select * from t1;
id c counter
2 a 2
insert into t1 (id, c) values
(NULL, 'b')
on duplicate key update id = values(id), counter = counter + 1;
select * from t1;
id c counter
2 a 2
3 b 1
truncate table t1;
insert into t1 (id, c) values (NULL, 'a');
select * from t1;
id c counter
1 a 1
insert into t1 (id, c) values (NULL, 'b'), (NULL, 'b')
on duplicate key update id = values(id), c = values(c), counter = counter + 1;
select * from t1;
id c counter
1 a 1
3 b 2
insert into t1 (id, c) values (NULL, 'a')
on duplicate key update id = values(id), c = values(c), counter = counter + 1;
select * from t1;
id c counter
3 b 2
4 a 2
drop table t1;
End of 5.0 tests

View file

@ -779,4 +779,32 @@ Field Type Null Key Default Extra
Name varchar(50) YES NULL
DROP VIEW v1;
DROP TABLE t1,t2,tv1,tv2;
create table t1 (a int, b int);
insert into t1 values
(NULL, 1),
(NULL, 2),
(NULL, 3),
(NULL, 4);
create table t2 (a int not null, primary key(a));
insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t3 (a int not null, primary key(a));
insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
flush status;
select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b;
a b a a
explain select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using index
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
We expect rnd_next=5, and read_key must be 0 because of short-cutting:
show status like 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 5
drop table t1, t2, t3;
End of 5.0 tests.

View file

@ -0,0 +1,2 @@
Variable_name Value
lower_case_table_names 1

View file

@ -0,0 +1,6 @@
drop table if exists t1;
create table t1 (id int) engine=myisam;
insert into t1 values (1);
create temporary table t2 select * from t1;
drop temporary table t2;
drop table t1;

View file

@ -3282,6 +3282,33 @@ v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI
drop database bug23491_original;
drop database bug23491_restore;
use test;
#
# Bug 27293: mysqldump crashes when dumping routines
# defined by a different user
#
# Bug #22761: mysqldump reports no errors when using
# --routines without mysql.proc privileges
#
create database mysqldump_test_db;
grant all privileges on mysqldump_test_db.* to user1;
grant all privileges on mysqldump_test_db.* to user2;
create procedure mysqldump_test_db.sp1() select 'hello';
DELIMITER ;;
-- insufficient privileges to SHOW CREATE PROCEDURE `sp1`
-- does user2 have permissions on mysql.proc?
DELIMITER ;
DELIMITER ;;
/*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`user1`@`%`*/ /*!50003 PROCEDURE `sp1`()
select 'hello' */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
DELIMITER ;
drop procedure sp1;
drop user user1;
drop user user2;
drop database mysqldump_test_db;
#
# End of 5.0 tests
#

View file

@ -649,3 +649,11 @@ pk a
6 NULL
7 4
DROP TABLE t1;
create table t1(a int primary key, b int, unique key(b)) engine=ndb;
insert ignore into t1 values (1,0), (2,0), (2,null), (3,null);
select * from t1 order by a;
a b
1 0
2 NULL
3 NULL
drop table t1;

View file

@ -607,6 +607,67 @@ x a sum(b)
2006-07-01 NULL 11
NULL NULL 11
drop table t1;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1
VALUES (2,10),(3,30),(2,40),(1,10),(2,30),(1,20),(2,10);
SELECT a, SUM(b) FROM t1 GROUP BY a WITH ROLLUP;
a SUM(b)
1 30
2 90
3 30
NULL 150
SELECT DISTINCT a, SUM(b) FROM t1 GROUP BY a WITH ROLLUP;
a SUM(b)
1 30
2 90
3 30
NULL 150
SELECT a, b, COUNT(*) FROM t1 GROUP BY a,b WITH ROLLUP;
a b COUNT(*)
1 10 1
1 20 1
1 NULL 2
2 10 2
2 30 1
2 40 1
2 NULL 4
3 30 1
3 NULL 1
NULL NULL 7
SELECT DISTINCT a, b, COUNT(*) FROM t1 GROUP BY a,b WITH ROLLUP;
a b COUNT(*)
1 10 1
1 20 1
1 NULL 2
2 10 2
2 30 1
2 40 1
2 NULL 4
3 30 1
3 NULL 1
NULL NULL 7
SELECT 'x', a, SUM(b) FROM t1 GROUP BY 1,2 WITH ROLLUP;
x a SUM(b)
x 1 30
x 2 90
x 3 30
x NULL 150
NULL NULL 150
SELECT DISTINCT 'x', a, SUM(b) FROM t1 GROUP BY 1,2 WITH ROLLUP;
x a SUM(b)
x 1 30
x 2 90
x 3 30
x NULL 150
NULL NULL 150
SELECT DISTINCT 'x', a, SUM(b) FROM t1 GROUP BY 1,2 WITH ROLLUP;
x a SUM(b)
x 1 30
x 2 90
x 3 30
x NULL 150
NULL NULL 150
DROP TABLE t1;
CREATE TABLE t1(id int, type char(1));
INSERT INTO t1 VALUES
(1,"A"),(2,"C"),(3,"A"),(4,"A"),(5,"B"),

View file

@ -3070,7 +3070,7 @@ found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and
@ -3083,7 +3083,7 @@ and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and

View file

@ -3053,7 +3053,7 @@ found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and
@ -3066,7 +3066,7 @@ and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and

View file

@ -3054,7 +3054,7 @@ found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and
@ -3067,7 +3067,7 @@ and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and

View file

@ -2990,7 +2990,7 @@ found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and
@ -3003,7 +3003,7 @@ and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and
@ -6004,7 +6004,7 @@ found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and
@ -6017,7 +6017,7 @@ and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and

View file

@ -3053,7 +3053,7 @@ found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and
@ -3066,7 +3066,7 @@ and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and

View file

@ -3053,7 +3053,7 @@ found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and
@ -3066,7 +3066,7 @@ and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' as datetime) and
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
c16= CAST('1991-01-01 01:01:01' as datetime) and

View file

@ -945,25 +945,19 @@ COUNT(*)
0
Warnings:
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 0
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050328 invalid';
COUNT(*)
0
Warnings:
Warning 1292 Incorrect datetime value: '20050328 invalid' for column 'date' at row 1
Warning 1292 Incorrect datetime value: '20050328 invalid' for column 'date' at row 1
Warning 1292 Truncated incorrect INTEGER value: '20050328 invalid'
Warning 1292 Truncated incorrect INTEGER value: '20050328 invalid'
Warning 1292 Incorrect datetime value: '20050328 invalid' for column 'date' at row 0
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid';
COUNT(*)
0
Warnings:
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 0
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0

View file

@ -394,13 +394,13 @@ EXPLAIN EXTENDED SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 43 NULL 2 Using where; Using index
Warnings:
Note 1003 select distinct `test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = 20020803)
Note 1003 select distinct `test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = _latin1'2002-08-03')
EXPLAIN EXTENDED SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 SUBQUERY t1 index NULL PRIMARY 43 NULL 2 Using where; Using index
Warnings:
Note 1003 select (select distinct `test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = 20020803)) AS `(SELECT DISTINCT date FROM t1 WHERE date='2002-08-03')`
Note 1003 select (select distinct `test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = _latin1'2002-08-03')) AS `(SELECT DISTINCT date FROM t1 WHERE date='2002-08-03')`
SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
date
2002-08-03
@ -4012,3 +4012,26 @@ WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
ERROR HY000: Invalid use of group function
SET @@sql_mode=default;
DROP TABLE t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 values (1),(1),(1),(1);
CREATE TABLE t2 (x INT);
INSERT INTO t1 values (1000),(1001),(1002);
SELECT SUM( (SELECT COUNT(a) FROM t2) ) FROM t1;
ERROR HY000: Invalid use of group function
SELECT SUM( (SELECT SUM(COUNT(a)) FROM t2) ) FROM t1;
ERROR HY000: Invalid use of group function
SELECT COUNT(1) FROM DUAL;
COUNT(1)
1
SELECT SUM( (SELECT AVG( (SELECT t1.a FROM t2) ) FROM DUAL) ) FROM t1;
ERROR HY000: Invalid use of group function
SELECT
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
FROM t1;
ERROR HY000: Invalid use of group function
SELECT t1.a as XXA,
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
FROM t1;
ERROR HY000: Invalid use of group function
DROP TABLE t1,t2;
End of 5.0 tests.

View file

@ -192,3 +192,75 @@ CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMA
SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6))
101112.098700
create table t1 (f1 date, f2 datetime, f3 timestamp);
insert into t1(f1) values(curdate());
select curdate() < now(), f1 < now(), cast(f1 as date) < now() from t1;
curdate() < now() f1 < now() cast(f1 as date) < now()
1 1 1
delete from t1;
insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01');
insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01');
insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01');
insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00');
insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01');
select f1, f3 from t1 where f1 >= '2001-02-05 00:00:00' and f3 <= '2001-04-15';
f1 f3
2001-02-05 2001-02-05 01:01:01
2001-03-10 2001-03-10 01:01:01
2001-04-15 2001-04-15 00:00:00
select f1, f3 from t1 where f1 >= '2001-2-5 0:0:0' and f2 <= '2001-4-15';
f1 f3
2001-02-05 2001-02-05 01:01:01
2001-03-10 2001-03-10 01:01:01
2001-04-15 2001-04-15 00:00:00
select f1, f2 from t1 where if(1, f1, 0) >= f2;
f1 f2
2001-02-05 2001-02-05 00:00:00
2001-03-10 2001-03-09 01:01:01
2001-04-15 2001-04-15 00:00:00
select 1 from dual where cast('2001-1-1 2:3:4' as date) = cast('2001-01-01' as datetime);
1
1
select f1, f2, f1 > f2, f1 = f2, f1 < f2 from t1;
f1 f2 f1 > f2 f1 = f2 f1 < f2
2001-01-01 2001-01-01 01:01:01 0 0 1
2001-02-05 2001-02-05 00:00:00 0 1 0
2001-03-10 2001-03-09 01:01:01 1 0 0
2001-04-15 2001-04-15 00:00:00 0 1 0
2001-05-20 2001-05-20 01:01:01 0 0 1
drop table t1;
create table t1 (f1 date, f2 datetime, f3 timestamp);
insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01');
insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01');
insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01');
insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00');
insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01');
select f2 from t1 where f2 between '2001-2-5' and '01-04-14';
f2
2001-02-05 00:00:00
2001-03-09 01:01:01
select f1, f2, f3 from t1 where f1 between f2 and f3;
f1 f2 f3
2001-02-05 2001-02-05 00:00:00 2001-02-05 01:01:01
2001-03-10 2001-03-09 01:01:01 2001-03-10 01:01:01
2001-04-15 2001-04-15 00:00:00 2001-04-15 00:00:00
select f1, f2, f3 from t1 where cast(f1 as datetime) between f2 and
cast(f3 as date);
f1 f2 f3
2001-02-05 2001-02-05 00:00:00 2001-02-05 01:01:01
2001-03-10 2001-03-09 01:01:01 2001-03-10 01:01:01
2001-04-15 2001-04-15 00:00:00 2001-04-15 00:00:00
select f2 from t1 where '2001-04-10 12:34:56' between f2 and '01-05-01';
f2
2001-01-01 01:01:01
2001-02-05 00:00:00
2001-03-09 01:01:01
select f2, f3 from t1 where '01-03-10' between f2 and f3;
f2 f3
2001-03-09 01:01:01 2001-03-10 01:01:01
select f2 from t1 where DATE(f2) between "2001-4-15" AND "01-4-15";
f2
2001-04-15 00:00:00
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
1
drop table t1;

View file

@ -763,7 +763,7 @@ truncate(99999999999999999999999999999999999999,31)
99999999999999999999999999999999999999.000000000000000000000000000000
select truncate(99.999999999999999999999999999999999999,31);
truncate(99.999999999999999999999999999999999999,31)
100.000000000000000000000000000000
99.999999999999999999999999999999
select truncate(99999999999999999999999999999999999999,-31);
truncate(99999999999999999999999999999999999999,-31)
99999990000000000000000000000000000000

View file

@ -457,3 +457,38 @@ a quux
2 0.100000000000000000000000000000
3 NULL
DROP TABLE t1;
set tmp_table_size=1024;
create table t1 (id int, a int, key idx(a));
create table t2 (id int unsigned not null auto_increment primary key, a int);
insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
insert into t2(a) select a from t2;
insert into t2(a) select a from t2;
insert into t2(a) select a from t2;
update t2 set a=id;
insert into t1 select * from t2;
select count(*) from t1 join t2 on (t1.a=t2.a);
count(*)
64
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
affected rows: 0
info: Rows matched: 64 Changed: 0 Warnings: 0
insert into t2(a) select a from t2;
update t2 set a=id;
truncate t1;
insert into t1 select * from t2;
select count(*) from t1 join t2 on (t1.a=t2.a);
count(*)
128
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
affected rows: 0
info: Rows matched: 128 Changed: 0 Warnings: 0
update t1 set a=1;
update t2 set a=1;
select count(*) from t1 join t2 on (t1.a=t2.a);
count(*)
16384
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
affected rows: 127
info: Rows matched: 128 Changed: 127 Warnings: 0
drop table t1,t2;
End of 5.0 tests

View file

@ -12,3 +12,10 @@ Warnings:
Warning 0 DATA DIRECTORY option ignored
Warning 0 INDEX DIRECTORY option ignored
drop table t1;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1,1);
EXPLAIN SELECT * FROM t1 WHERE b = (SELECT max(2));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
End of 5.0 tests.

View file

@ -44,7 +44,8 @@ if (0)
# ------------------------------------------------------------------------------
# prepare a variable to be able to suppress machine dependant diffs
# this can be used in: --replace_result $SERVER_NAME <SERVER_NAME>
let $SERVER_NAME= `SELECT DISTINCT host FROM mysql.user WHERE host LIKE "%\%" AND host NOT In ("localhost", "127.0.0.1", "%")`;
# let $SERVER_NAME= `SELECT DISTINCT host FROM mysql.user WHERE host LIKE "%\%" AND host NOT In ("localhost", "127.0.0.1", "%")`;
let $SERVER_NAME= `SELECT DISTINCT host FROM mysql.user WHERE host NOT In ("localhost", "127.0.0.1", "%")`;
################################################################################

View file

@ -105,7 +105,7 @@ SELECT DISTINCT u,
AS Server_Clean
FROM db_datadict.vu1;
--replace_result $SERVER_NAME <SERVER_NAME>
SELECT * FROM db_datadict.vu;
SELECT * FROM db_datadict.vu order by u;
delimiter //;
CREATE PROCEDURE db_datadict.sp_1()
@ -141,8 +141,9 @@ if ($have_bug_11589)
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -152,7 +153,8 @@ SELECT * FROM tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM tables
WHERE NOT( table_schema = 'information_schema');
--horizontal_results
@ -177,7 +179,7 @@ select count(*) from routines;
select * from statistics;
select * from views;
--replace_result $SERVER_NAME <SERVER_NAME>
select * from user_privileges;
select * from user_privileges order by grantee, privilege_type;
select * from schema_privileges;
select * from table_privileges;
select * from column_privileges;
@ -199,7 +201,8 @@ select concat("Table or view '", table_name,
--replace_result $SERVER_NAME <SERVER_NAME>
select grantee as "user's having select privilege",
substring( grantee, length(SUBSTRING_INDEX(grantee,_utf8'@',1))+2 )
from user_privileges where privilege_type = 'select';
from user_privileges where privilege_type = 'select'
order by grantee;
select all table_schema from schema_privileges limit 0,5;
@ -293,13 +296,14 @@ select * from information_schema.schemata ORDER BY 2 DESC;
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHRCK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--vertical_results
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -309,7 +313,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHRCK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--horizontal_results
@ -385,7 +390,7 @@ select concat(table_schema, ', ', table_name) "Table_info"
from tables ORDER BY 1;
--replace_result $SERVER_NAME <SERVER_NAME>
select distinct grantee from user_privileges;
select distinct grantee from user_privileges order by grantee, privilege_type;
select * from schema_privileges where table_catalog is null limit 0, 5;
select * from table_privileges where grantee like '%r%' limit 0, 5;
@ -399,7 +404,7 @@ select * from schemata limit 0,5;
--replace_result $SERVER_NAME <SERVER_NAME>
select distinct grantee from user_privileges;
--replace_result $SERVER_NAME <SERVER_NAME>
select all grantee from user_privileges;
select all grantee from user_privileges order by grantee, privilege_type;
select id , character_set_name from collations order by id asc limit 10;
@ -455,8 +460,9 @@ eval SELECT *
LINES TERMINATED BY '\n'
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
# FIXME: why do we get different error numbers with and without OUTFILE ?
#FIXME this should fail! --error 1146
# The above will fail with access error as long as
# BUBG#28181 - a regression introduced in 5.0.42 is not fixed
eval SELECT *
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
@ -469,7 +475,9 @@ eval SELECT *
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5;
# FIXME 3.2.1.2: why do we get different error numbers with and without OUTFILE ?
# The above will fail with access error as long as
# BUBG#28181 - a regression introduced in 5.0.42 is not fixed
eval SELECT *
FROM schemata LIMIT 0, 5;
@ -479,8 +487,9 @@ eval SELECT *
LINES TERMINATED BY '\n'
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
# FIXME: why do we get different error numbers with and without OUTFILE ?
#FIXME this should fail! --error 1146
# The above will fail with access error as long as
# BUBG#28181 - a regression introduced in 5.0.42 is not fixed
eval SELECT *
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
@ -3014,12 +3023,13 @@ GRANT SELECT ON db_datadict.v3 to 'user_3'@'localhost';
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -3029,7 +3039,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--enable_ps_protocol
@ -3049,12 +3060,13 @@ connect (user_12_2, localhost, user_2, , db_datadict);
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -3064,7 +3076,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--enable_ps_protocol
@ -3085,12 +3098,13 @@ connect (user_12_3, localhost, user_3, , db_datadict);
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -3100,7 +3114,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--enable_ps_protocol
@ -3121,12 +3136,13 @@ connection default;
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -3136,7 +3152,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--enable_ps_protocol

View file

@ -36,7 +36,7 @@ eval select table_name, index_schema, index_name, index_type
--replace_result $SERVER_NAME <SERVER_NAME>
eval select *
from information_schema.user_privileges;
from information_schema.user_privileges order by grantee, privilege_type;
# where grantee="'u_6_401013'@'%'";
eval select *

View file

@ -1,11 +0,0 @@
. Just show the version string for which the results in suite
. funcs_1 have been checked.
.
. I know that the .result file of this check needs to
. updated with each new version --- THIS IS INTENDED!
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
funcs_1 checked with version: 5.0.36
Warnings:
Warning 1466 Leading spaces are removed from name ' '

File diff suppressed because it is too large Load diff

View file

@ -3814,13 +3814,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values`
@ -3831,13 +3829,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
DROP VIEW v1;

View file

@ -484,8 +484,9 @@ BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
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 'SET @counter1 = @counter1 + 1;
END' at line 4
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 'WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END' at line 3
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;

View file

@ -448,7 +448,8 @@ SET @x=0;
CREATE or REPLACE VIEW v1 AS Select 1 INTO @x;
ERROR HY000: View's SELECT contains a 'INTO' clause
Select @x;
ERROR HY000: View's SELECT contains a variable or parameter
@x
0
CREATE or REPLACE VIEW v1 AS Select 1
FROM (SELECT 1 FROM t1) my_table;
ERROR HY000: View's SELECT contains a subquery in the FROM clause
@ -585,7 +586,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
CREATE or REPLACE view v1 as Select f59, f60
from tb2 by group f59 ;
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 'by group f59' at line 2
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.5
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE VIEW v1 SELECT * FROM tb2 limit 100 ;
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 'SELECT * FROM tb2 limit 100' at line 1
@ -605,7 +608,9 @@ CREATE VIEW v1 SELECT 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 'SELECT 1' at line 1
CREATE VIEW v1 AS ;
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 '' at line 1
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.6
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE or REPLACE VIEW v1
as SELECT * from tb2 limit 100 ;
@ -1790,7 +1795,9 @@ ERROR HY000: View's SELECT contains a subquery in the FROM clause
SELECT * FROM test.v1 ;
ERROR 42S02: Table 'test.v1' doesn't exist
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.40
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Set @var1 = 'ABC' ;
Set @var2 = 'XYZ' ;
@ -1799,7 +1806,9 @@ ERROR HY000: View's SELECT contains a variable or parameter
CREATE VIEW test.v1 AS SELECT @@global.sort_buffer_size;
ERROR HY000: View's SELECT contains a variable or parameter
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.41
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Drop procedure if exists sp1 ;
Create procedure sp1() DETERMINISTIC
@ -1816,7 +1825,9 @@ Warnings:
Note 1051 Unknown table 'test.v1'
Drop procedure sp1 ;
ERROR 42000: PROCEDURE test.sp1 does not exist
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.42
--------------------------------------------------------------------------------
Drop VIEW if exists test.v1 ;
CREATE TEMPORARY VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2 ;
@ -1828,7 +1839,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT * FROM test.tb2 limit 2' at line 1
Drop view if exists test.v1 ;
Use test;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.43
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
CREATE VIEW test.v1 AS SELECT f59,f60 FROM test.tb2;
INSERT INTO test.v1 values(122,432);

View file

@ -1,2 +0,0 @@
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3039: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3050: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning

File diff suppressed because it is too large Load diff

View file

@ -3814,13 +3814,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values`
@ -3831,13 +3829,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
DROP VIEW v1;

View file

@ -480,8 +480,9 @@ BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
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 'SET @counter1 = @counter1 + 1;
END' at line 4
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 'WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END' at line 3
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;

View file

@ -452,7 +452,8 @@ SET @x=0;
CREATE or REPLACE VIEW v1 AS Select 1 INTO @x;
ERROR HY000: View's SELECT contains a 'INTO' clause
Select @x;
ERROR HY000: View's SELECT contains a variable or parameter
@x
0
CREATE or REPLACE VIEW v1 AS Select 1
FROM (SELECT 1 FROM t1) my_table;
ERROR HY000: View's SELECT contains a subquery in the FROM clause
@ -589,7 +590,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
CREATE or REPLACE view v1 as Select f59, f60
from tb2 by group f59 ;
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 'by group f59' at line 2
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.5
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE VIEW v1 SELECT * FROM tb2 limit 100 ;
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 'SELECT * FROM tb2 limit 100' at line 1
@ -609,7 +612,9 @@ CREATE VIEW v1 SELECT 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 'SELECT 1' at line 1
CREATE VIEW v1 AS ;
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 '' at line 1
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.6
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE or REPLACE VIEW v1
as SELECT * from tb2 limit 100 ;
@ -1794,7 +1799,9 @@ ERROR HY000: View's SELECT contains a subquery in the FROM clause
SELECT * FROM test.v1 ;
ERROR 42S02: Table 'test.v1' doesn't exist
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.40
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Set @var1 = 'ABC' ;
Set @var2 = 'XYZ' ;
@ -1803,7 +1810,9 @@ ERROR HY000: View's SELECT contains a variable or parameter
CREATE VIEW test.v1 AS SELECT @@global.sort_buffer_size;
ERROR HY000: View's SELECT contains a variable or parameter
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.41
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Drop procedure if exists sp1 ;
Create procedure sp1() DETERMINISTIC
@ -1820,7 +1829,9 @@ Warnings:
Note 1051 Unknown table 'test.v1'
Drop procedure sp1 ;
ERROR 42000: PROCEDURE test.sp1 does not exist
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.42
--------------------------------------------------------------------------------
Drop VIEW if exists test.v1 ;
CREATE TEMPORARY VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2 ;
@ -1832,7 +1843,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT * FROM test.tb2 limit 2' at line 1
Drop view if exists test.v1 ;
Use test;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.43
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
CREATE VIEW test.v1 AS SELECT f59,f60 FROM test.tb2;
INSERT INTO test.v1 values(122,432);

View file

@ -1,2 +0,0 @@
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3039: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3050: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning

File diff suppressed because it is too large Load diff

View file

@ -3814,13 +3814,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values`
@ -3831,13 +3829,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
DROP VIEW v1;

View file

@ -484,8 +484,9 @@ BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
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 'SET @counter1 = @counter1 + 1;
END' at line 4
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 'WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END' at line 3
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;

View file

@ -470,7 +470,8 @@ SET @x=0;
CREATE or REPLACE VIEW v1 AS Select 1 INTO @x;
ERROR HY000: View's SELECT contains a 'INTO' clause
Select @x;
ERROR HY000: View's SELECT contains a variable or parameter
@x
0
CREATE or REPLACE VIEW v1 AS Select 1
FROM (SELECT 1 FROM t1) my_table;
ERROR HY000: View's SELECT contains a subquery in the FROM clause
@ -607,7 +608,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
CREATE or REPLACE view v1 as Select f59, f60
from tb2 by group f59 ;
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 'by group f59' at line 2
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.5
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE VIEW v1 SELECT * FROM tb2 limit 100 ;
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 'SELECT * FROM tb2 limit 100' at line 1
@ -627,7 +630,9 @@ CREATE VIEW v1 SELECT 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 'SELECT 1' at line 1
CREATE VIEW v1 AS ;
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 '' at line 1
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.6
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE or REPLACE VIEW v1
as SELECT * from tb2 limit 100 ;
@ -1812,7 +1817,9 @@ ERROR HY000: View's SELECT contains a subquery in the FROM clause
SELECT * FROM test.v1 ;
ERROR 42S02: Table 'test.v1' doesn't exist
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.40
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Set @var1 = 'ABC' ;
Set @var2 = 'XYZ' ;
@ -1821,7 +1828,9 @@ ERROR HY000: View's SELECT contains a variable or parameter
CREATE VIEW test.v1 AS SELECT @@global.sort_buffer_size;
ERROR HY000: View's SELECT contains a variable or parameter
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.41
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Drop procedure if exists sp1 ;
Create procedure sp1() DETERMINISTIC
@ -1838,7 +1847,9 @@ Warnings:
Note 1051 Unknown table 'test.v1'
Drop procedure sp1 ;
ERROR 42000: PROCEDURE test.sp1 does not exist
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.42
--------------------------------------------------------------------------------
Drop VIEW if exists test.v1 ;
CREATE TEMPORARY VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2 ;
@ -1850,7 +1861,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT * FROM test.tb2 limit 2' at line 1
Drop view if exists test.v1 ;
Use test;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.43
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
CREATE VIEW test.v1 AS SELECT f59,f60 FROM test.tb2;
INSERT INTO test.v1 values(122,432);

View file

@ -1,2 +0,0 @@
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3039: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3050: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning

View file

@ -1,29 +0,0 @@
#### suite/funcs_1/t/a_version_check.test
#
# just a simple check of the version to be sure the correct server version is
# checked against the funcs_1 tests.
# just show machine and version to be sure we are testing the correct files
#
let $message= . Just show the version string for which the results in suite
. funcs_1 have been checked.
.
. I know that the .result file of this check needs to
. updated with each new version --- THIS IS INTENDED!;
--source include/show_msg.inc
--disable_query_log
SELECT CONCAT('funcs_1 checked with version: ', SUBSTR(version(), 1, 6 ) ) AS " ";
#SELECT CONCAT('aa = ', 'bb');
#SELECT CONCAT('aa = ', 'bb') AS " ";
if (0)
{
# these more detailed results create differences between the OS.
# mioght be used later when we enable OS dependent .result files
--vertical_results
SELECT @@version_compile_os AS 'vers_comp_os', current_date;
SHOW VARIABLES LIKE 'vers%';
--horizontal_results
}

View file

@ -10,6 +10,6 @@
#
##############################################################################
innodb_storedproc: switched off (too much changed output from WL#2984, needs to be checked)
memory_storedproc: switched off (too much changed output from WL#2984, needs to be checked)
myisam_storedproc: switched off (too much changed output from WL#2984, needs to be checked)
innodb_storedproc: (changes of WL#2984, using storeproc_nn instead)
memory_storedproc: (changes of WL#2984, using storeproc_nn instead)
myisam_storedproc: (changes of WL#2984, using storeproc_nn instead)

View file

@ -3036,7 +3036,9 @@ let $sublevel= `SELECT @max_level`;
eval CREATE VIEW test1.v$level AS SELECT f1, f2
FROM test3.t1 tab1 NATURAL JOIN test1.v$sublevel tab2;
eval SHOW CREATE VIEW test1.v$level;
--eror 1116
# the following line as written as '--eror 1116' and the command
# is successful so assuming no expected error was intended
# --error 1116
eval SELECT CAST(f1 AS SIGNED INTEGER) AS f1,
CAST(f2 AS CHAR) AS f2 FROM test1.v$level;
let $message= The output of following EXPLAIN is deactivated, because the result
@ -3047,7 +3049,9 @@ if (1)
{
--disable_result_log
}
--eror 1116
# the following line as written as '--eror 1116' and the command
# is successful so assuming no expected error was intended
# --error 1116
eval EXPLAIN SELECT CAST(f1 AS SIGNED INTEGER) AS f1,
CAST(f2 AS CHAR) AS f2 FROM test1.v$level;
if (1)

View file

@ -636,3 +636,29 @@ ALTER TABLE t1 ADD d INT;
ALTER TABLE t1 ADD KEY (d(20));
DROP TABLE t1;
# Bug#25262 Auto Increment lost when changing Engine type
#
create table t1(id int(8) primary key auto_increment) engine=heap;
insert into t1 values (null);
insert into t1 values (null);
select * from t1;
# Set auto increment to 50
alter table t1 auto_increment = 50;
# Alter to myisam
alter table t1 engine = myisam;
# This insert should get id 50
insert into t1 values (null);
select * from t1;
# Alter to heap again
alter table t1 engine = heap;
insert into t1 values (null);
select * from t1;
drop table t1;

View file

@ -82,11 +82,6 @@ select format(col2,6) from t1 where col1=7;
drop table t1;
#
# Bug #10083 (round doesn't increase decimals)
#
select round(150, 2);
#
# Bug @10632 (Ceiling function returns wrong answer)
#
@ -177,3 +172,37 @@ select format(t2.f2-t2.f1+1,0) from t1,t2
where t1.f2 = t2.f3 order by t1.f1;
drop table t1, t2;
set names default;
# Bug 24912 -- misc functions have trouble with unsigned
select cast(-2 as unsigned), 18446744073709551614, -2;
select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2);
select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2);
select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2);
select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2);
select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2);
select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1);
select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2);
select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1);
select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2);
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
select round(1e0, -309), truncate(1e0, -309);
select round(1e1,308), truncate(1e1, 308);
select round(1e1, 2147483648), truncate(1e1, 2147483648);
select round(1.1e1, 4294967295), truncate(1.1e1, 4294967295);
select round(1.12e1, 4294967296), truncate(1.12e1, 4294967296);
select round(1.5, 2147483640), truncate(1.5, 2147483640);
select round(1.5, -2147483649), round(1.5, 2147483648);
select truncate(1.5, -2147483649), truncate(1.5, 2147483648);
select round(1.5, -4294967296), round(1.5, 4294967296);
select truncate(1.5, -4294967296), truncate(1.5, 4294967296);
select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808);
select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808);
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615);
select round(18446744073709551614, -1), truncate(18446744073709551614, -1);
select round(4, -4294967200), truncate(4, -4294967200);
select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3);
select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2);
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
--echo End of 5.0 tests

View file

@ -752,3 +752,17 @@ SELECT b FROM t1 AS t1_outer GROUP BY a HAVING t1_outer.a IN
HAVING SUM(t1_inner.b)+t1_outer.b > 5);
DROP TABLE t1;
SET SQL_MODE = '';
#
# Bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode.
#
SET SQL_MODE = 'ONLY_FULL_GROUP_BY';
create table t1(f1 int, f2 int);
--error 1055
select * from t1 group by f1;
--error 1055
select * from t1 group by f2;
select * from t1 group by f1, f2;
--error 1055
select t1.f1,t.* from t1, t1 t group by 1;
drop table t1;
SET SQL_MODE = '';

View file

@ -139,6 +139,36 @@ eval select STRCMP("$before", "$after") as "Before and after comparison";
connection default;
drop table t1;
disconnect con1;
#
# Bug #13191: INSERT...ON DUPLICATE KEY UPDATE of UTF-8 string fields
# used in partial unique indices.
#
CREATE TABLE t1(c1 TEXT, UNIQUE (c1(1)), cnt INT DEFAULT 1)
ENGINE=INNODB CHARACTER SET UTF8;
INSERT INTO t1 (c1) VALUES ('1a');
SELECT * FROM t1;
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1(c1 VARCHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
ENGINE=INNODB CHARACTER SET UTF8;
INSERT INTO t1 (c1) VALUES ('1a');
SELECT * FROM t1;
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1(c1 CHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
ENGINE=INNODB CHARACTER SET UTF8;
INSERT INTO t1 (c1) VALUES ('1a');
SELECT * FROM t1;
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
SELECT * FROM t1;
DROP TABLE t1;
--echo End of 4.1 tests
#
# Bug #12882 min/max inconsistent on empty table
@ -442,4 +472,50 @@ drop table test;
set global query_cache_type=@save_qcache_type;
set global query_cache_size=@save_qcache_size;
-- source include/have_innodb.inc
#
# Bug #27650: INSERT fails after multi-row INSERT of the form:
# INSERT INTO t (id...) VALUES (NULL...) ON DUPLICATE KEY UPDATE id=VALUES(id)
#
create table t1(
id int auto_increment,
c char(1) not null,
counter int not null default 1,
primary key (id),
unique key (c)
) engine=innodb;
insert into t1 (id, c) values
(NULL, 'a'),
(NULL, 'a')
on duplicate key update id = values(id), counter = counter + 1;
select * from t1;
insert into t1 (id, c) values
(NULL, 'b')
on duplicate key update id = values(id), counter = counter + 1;
select * from t1;
truncate table t1;
insert into t1 (id, c) values (NULL, 'a');
select * from t1;
insert into t1 (id, c) values (NULL, 'b'), (NULL, 'b')
on duplicate key update id = values(id), c = values(c), counter = counter + 1;
select * from t1;
insert into t1 (id, c) values (NULL, 'a')
on duplicate key update id = values(id), c = values(c), counter = counter + 1;
select * from t1;
drop table t1;
--echo End of 5.0 tests

View file

@ -610,4 +610,27 @@ DESCRIBE tv2;
DROP VIEW v1;
DROP TABLE t1,t2,tv1,tv2;
# BUG#27939: Early NULLs filtering doesn't work for eq_ref access
create table t1 (a int, b int);
insert into t1 values
(NULL, 1),
(NULL, 2),
(NULL, 3),
(NULL, 4);
create table t2 (a int not null, primary key(a));
insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t3 (a int not null, primary key(a));
insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
flush status;
select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b;
explain select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b;
--echo We expect rnd_next=5, and read_key must be 0 because of short-cutting:
show status like 'Handler_read%';
drop table t1, t2, t3;
--echo End of 5.0 tests.

View file

@ -0,0 +1,2 @@
--lower-case-table-names=1
--tmpdir=$MYSQLTEST_VARDIR/tmp/MixedCase

View file

@ -0,0 +1,6 @@
# This test requires a non-lowercase tmpdir directory on a case-sensitive
# filesystem.
d="$MYSQLTEST_VARDIR/tmp/MixedCase"
test -d "$d" || mkdir "$d"
rm -f "$d"/*

View file

@ -0,0 +1,12 @@
--source include/have_case_sensitive_file_system.inc
--source include/have_lowercase1.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (id int) engine=myisam;
insert into t1 values (1);
create temporary table t2 select * from t1;
drop temporary table t2;
drop table t1;

View file

@ -1495,6 +1495,41 @@ drop database bug23491_original;
drop database bug23491_restore;
use test;
--echo #
--echo # Bug 27293: mysqldump crashes when dumping routines
--echo # defined by a different user
--echo #
--echo # Bug #22761: mysqldump reports no errors when using
--echo # --routines without mysql.proc privileges
--echo #
create database mysqldump_test_db;
grant all privileges on mysqldump_test_db.* to user1;
grant all privileges on mysqldump_test_db.* to user2;
connect (user27293,localhost,user1,,mysqldump_test_db,$MASTER_MYPORT,$MASTER_MYSOCK);
connection user27293;
create procedure mysqldump_test_db.sp1() select 'hello';
--error 2
--exec $MYSQL_DUMP -f --compact --user=user2 --password= -h 127.0.0.1 -P $MASTER_MYPORT --routines mysqldump_test_db
--exec $MYSQL_DUMP -f --compact --user=user1 --password= -h 127.0.0.1 -P $MASTER_MYPORT --routines mysqldump_test_db
drop procedure sp1;
connection default;
drop user user1;
drop user user2;
drop database mysqldump_test_db;
--echo #
--echo # End of 5.0 tests
--echo #

View file

@ -630,4 +630,13 @@ INSERT IGNORE INTO t1 VALUES (4,NULL),(5,NULL),(6,NULL),(7,4);
SELECT * FROM t1 ORDER BY pk;
DROP TABLE t1;
#
# Bug #27980 INSERT IGNORE wrongly ignores NULLs in unique index
#
create table t1(a int primary key, b int, unique key(b)) engine=ndb;
insert ignore into t1 values (1,0), (2,0), (2,null), (3,null);
select * from t1 order by a;
drop table t1;
# End of 4.1 tests

View file

@ -292,6 +292,25 @@ select left(a,10), a, sum(b) from t1 group by 1,2 with rollup;
select left(a,10) x, a, sum(b) from t1 group by x,a with rollup;
drop table t1;
#
# Bug #24856: ROLLUP by const item in a query with DISTINCT
#
CREATE TABLE t1 (a int, b int);
INSERT INTO t1
VALUES (2,10),(3,30),(2,40),(1,10),(2,30),(1,20),(2,10);
SELECT a, SUM(b) FROM t1 GROUP BY a WITH ROLLUP;
SELECT DISTINCT a, SUM(b) FROM t1 GROUP BY a WITH ROLLUP;
SELECT a, b, COUNT(*) FROM t1 GROUP BY a,b WITH ROLLUP;
SELECT DISTINCT a, b, COUNT(*) FROM t1 GROUP BY a,b WITH ROLLUP;
SELECT 'x', a, SUM(b) FROM t1 GROUP BY 1,2 WITH ROLLUP;
SELECT DISTINCT 'x', a, SUM(b) FROM t1 GROUP BY 1,2 WITH ROLLUP;
SELECT DISTINCT 'x', a, SUM(b) FROM t1 GROUP BY 1,2 WITH ROLLUP;
DROP TABLE t1;
# End of 4.1 tests
#
@ -339,6 +358,3 @@ SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) as t;
DROP TABLE t1;

View file

@ -2845,3 +2845,33 @@ SELECT a FROM t1 t0
SET @@sql_mode=default;
DROP TABLE t1;
#
# Bug #27363: nested aggregates in outer, subquery / sum(select
# count(outer))
#
CREATE TABLE t1 (a INT); INSERT INTO t1 values (1),(1),(1),(1);
CREATE TABLE t2 (x INT); INSERT INTO t1 values (1000),(1001),(1002);
--error ER_INVALID_GROUP_FUNC_USE
SELECT SUM( (SELECT COUNT(a) FROM t2) ) FROM t1;
--error ER_INVALID_GROUP_FUNC_USE
SELECT SUM( (SELECT SUM(COUNT(a)) FROM t2) ) FROM t1;
SELECT COUNT(1) FROM DUAL;
--error ER_INVALID_GROUP_FUNC_USE
SELECT SUM( (SELECT AVG( (SELECT t1.a FROM t2) ) FROM DUAL) ) FROM t1;
--error ER_INVALID_GROUP_FUNC_USE
SELECT
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
FROM t1;
--error ER_INVALID_GROUP_FUNC_USE
SELECT t1.a as XXA,
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
FROM t1;
DROP TABLE t1,t2;
--echo End of 5.0 tests.

View file

@ -141,3 +141,40 @@ SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6));
SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
#
# Bug#27590: Wrong DATE/DATETIME comparison.
#
create table t1 (f1 date, f2 datetime, f3 timestamp);
insert into t1(f1) values(curdate());
select curdate() < now(), f1 < now(), cast(f1 as date) < now() from t1;
delete from t1;
insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01');
insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01');
insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01');
insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00');
insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01');
select f1, f3 from t1 where f1 >= '2001-02-05 00:00:00' and f3 <= '2001-04-15';
select f1, f3 from t1 where f1 >= '2001-2-5 0:0:0' and f2 <= '2001-4-15';
select f1, f2 from t1 where if(1, f1, 0) >= f2;
select 1 from dual where cast('2001-1-1 2:3:4' as date) = cast('2001-01-01' as datetime);
select f1, f2, f1 > f2, f1 = f2, f1 < f2 from t1;
drop table t1;
#
# Bug#16377: Wrong DATE/DATETIME comparison in BETWEEN function.
#
create table t1 (f1 date, f2 datetime, f3 timestamp);
insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01');
insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01');
insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01');
insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00');
insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01');
select f2 from t1 where f2 between '2001-2-5' and '01-04-14';
select f1, f2, f3 from t1 where f1 between f2 and f3;
select f1, f2, f3 from t1 where cast(f1 as datetime) between f2 and
cast(f3 as date);
select f2 from t1 where '2001-04-10 12:34:56' between f2 and '01-05-01';
select f2, f3 from t1 where '01-03-10' between f2 and f3;
select f2 from t1 where DATE(f2) between "2001-4-15" AND "01-4-15";
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
drop table t1;

View file

@ -376,3 +376,58 @@ INSERT INTO t1( a )
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug #22364: Inconsistent "matched rows" when executing UPDATE
#
connect (con1,localhost,root,,test);
connection con1;
set tmp_table_size=1024;
# Create the test tables
create table t1 (id int, a int, key idx(a));
create table t2 (id int unsigned not null auto_increment primary key, a int);
insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
insert into t2(a) select a from t2;
insert into t2(a) select a from t2;
insert into t2(a) select a from t2;
update t2 set a=id;
insert into t1 select * from t2;
# Check that the number of matched rows is correct when the temporary
# table is small enough to not be converted to MyISAM
select count(*) from t1 join t2 on (t1.a=t2.a);
--enable_info
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
--disable_info
# Increase table sizes
insert into t2(a) select a from t2;
update t2 set a=id;
truncate t1;
insert into t1 select * from t2;
# Check that the number of matched rows is correct when the temporary
# table has to be converted to MyISAM
select count(*) from t1 join t2 on (t1.a=t2.a);
--enable_info
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
--disable_info
# Check that the number of matched rows is correct when there are duplicate
# key errors
update t1 set a=1;
update t2 set a=1;
select count(*) from t1 join t2 on (t1.a=t2.a);
--enable_info
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
--disable_info
drop table t1,t2;
connection default;
disconnect con1;
--echo End of 5.0 tests

View file

@ -27,3 +27,11 @@ CREATE TABLE t1 ( `ID` int(6) ) data directory 'c:/tmp/' index directory 'c:/tmp
drop table t1;
# End of 4.1 tests
#
# Bug #27811: The variable 'join_tab' is being used without being defined
#
CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (1,1);
EXPLAIN SELECT * FROM t1 WHERE b = (SELECT max(2));
--echo End of 5.0 tests.

View file

@ -877,8 +877,8 @@ void my_print_default_files(const char *conf_file)
fputs(name,stdout);
}
}
puts("");
}
puts("");
}
void print_defaults(const char *conf_file, const char **groups)

View file

@ -111,6 +111,11 @@ int my_copy(const char *from, const char *to, myf MyFlags)
err:
if (from_file >= 0) VOID(my_close(from_file,MyFlags));
if (to_file >= 0) VOID(my_close(to_file,MyFlags));
if (to_file >= 0)
{
VOID(my_close(to_file, MyFlags));
/* attempt to delete the to-file we've partially written */
VOID(my_delete(to, MyFlags));
}
DBUG_RETURN(-1);
} /* my_copy */

View file

@ -18,7 +18,7 @@
#include <ndb_global.h>
#include "TimeModule.hpp"
static const char* cMonth[] = { "x", "January", "February", "Mars", "April", "May", "June",
static const char* cMonth[] = { "x", "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
static const char* cDay[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",

View file

@ -90,20 +90,20 @@ EXTRA_DIST= $(BUILT_SOURCES) comp_err.def install_test_db.ncf \
# Build init_db.sql from the files that contain
# the system tables for this version of MySQL plus any commands
init_db.sql: $(top_srcdir)/scripts/mysql_system_tables.sql \
$(top_srcdir)/scripts/mysql_system_tables_data.sql
$(top_srcdir)/scripts/mysql_system_tables_data.sql
@echo "Building $@";
@echo "CREATE DATABASE mysql;" > $@;
@echo "CREATE DATABASE test;" >> $@;
@echo "use mysql;" >> $@;
@cat $(top_srcdir)/scripts/mysql_system_tables.sql \
$(top_srcdir)/scripts/mysql_system_tables_fix.sql >> $@;
$(top_srcdir)/scripts/mysql_system_tables_fix.sql >> $@;
# Build test_db.sql from init_db.sql plus
# some test data
test_db.sql: init_db.sql $(top_srcdir)/scripts/mysql_test_data_timezone.sql
@echo "Building $@";
@cat init_db.sql \
$(top_srcdir)/scripts/mysql_test_data_timezone.sql >> $@;
$(top_srcdir)/scripts/mysql_test_data_timezone.sql >> $@;
endif

View file

@ -16,9 +16,9 @@
## Process this file with automake to create Makefile.in
BUILT_SOURCES = mysql_fix_privilege_tables.sql \
mysql_fix_privilege_tables_sql.c
mysql_fix_privilege_tables_sql.c
noinst_PROGRAMS = comp_sql
EXTRA_PROGRAMS = comp_sql
bin_SCRIPTS = @server_scripts@ \
msql2mysql \
@ -70,6 +70,7 @@ EXTRA_DIST = $(EXTRA_SCRIPTS) \
mysqlaccess.conf \
mysqlbug \
make_win_bin_dist \
mysql_fix_privilege_tables_sql.c \
mysql_system_tables_fix.sql \
CMakeLists.txt
@ -98,13 +99,11 @@ CLEANFILES = @server_scripts@ \
mysql_tableinfo \
mysql_upgrade_shell \
mysqld_multi \
make_win_src_distribution \
mysql_fix_privilege_tables.sql \
mysql_fix_privilege_tables_sql.c
make_win_src_distribution
# mysqlbug should be distributed built so that people can report build
# failures with it.
DISTCLEANFILES = mysqlbug
DISTCLEANFILES = $(BUILT_SOURCES) mysqlbug
# We want the right version and configure comand line in mysqlbug
mysqlbug: ${top_builddir}/config.status mysqlbug.sh
@ -120,11 +119,14 @@ mysql_fix_privilege_tables.sql: mysql_system_tables.sql \
#
# Build mysql_fix_privilege_tables_sql.c from
# mysql_fix_privileges_tables.sql using comp_sql
# The "sleep" ensures the generated file has a younger timestamp than its source
# (which may have been generated in this very same "make" run).
#
mysql_fix_privilege_tables_sql.c: comp_sql.c mysql_fix_privilege_tables.sql
$(MAKE) $(AM_MAKEFLAGS) comp_sql$(EXEEXT)
sleep 2
$(top_builddir)/scripts/comp_sql$(EXEEXT) \
mysql_fix_privilege_tables \
mysql_fix_privilege_tables \
$(top_srcdir)/scripts/mysql_fix_privilege_tables.sql $@

View file

@ -79,7 +79,10 @@ parse_arguments() {
then
# This sed command makes sure that any special chars are quoted,
# so the arg gets passed exactly to the server.
args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'`
# XXX: This is broken; true fix requires using eval and proper
# quoting of every single arg ($basedir, $ldata, etc.)
#args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'`
args="$args $arg"
fi
;;
esac
@ -151,6 +154,7 @@ else
if test -f $i/$fill_help_tables
then
pkgdatadir=$i
break
fi
done

View file

@ -4,9 +4,10 @@ use Getopt::Long;
use POSIX qw(strftime);
$|=1;
$VER="2.15";
$VER="2.16";
my @defaults_options; # Leading --no-defaults, --defaults-file, etc.
$opt_config_file = undef();
$opt_example = 0;
$opt_help = 0;
$opt_log = undef();
@ -49,54 +50,52 @@ sub main
print "MySQL distribution.\n";
$my_print_defaults_exists= 0;
}
if ($my_print_defaults_exists)
# Remove leading defaults options from @ARGV
while (@ARGV > 0)
{
foreach my $arg (@ARGV)
{
if ($arg =~ m/^--config-file=(.*)/)
{
if (!length($1))
{
die "Option config-file requires an argument\n";
}
elsif (!( -e $1 && -r $1))
{
die "Option file '$1' doesn't exists, or is not readable\n";
}
else
{
$opt_config_file= $1;
if (!($opt_config_file =~ m/\//))
{
# No path. Use current working directory
$opt_config_file= "./" . $opt_config_file;
}
}
}
}
my $com= "my_print_defaults ";
$com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
$com.= "mysqld_multi";
my @defops = `$com`;
chop @defops;
splice @ARGV, 0, 0, @defops;
last unless $ARGV[0] =~
/^--(?:no-defaults$|(?:defaults-file|defaults-extra-file)=)/;
push @defaults_options, (shift @ARGV);
}
if (!GetOptions("help","example","version","mysqld=s","mysqladmin=s",
"config-file=s","user=s","password=s","log=s","no-log",
"tcp-ip", "silent","verbose"))
# Handle deprecated --config-file option: convert to --defaults-extra-file
foreach my $arg (@ARGV)
{
if ($arg =~ m/^--config-file=(.*)/)
{
# Put it at the beginning of the list, so it has lower precedence
# than a correct --defaults-extra-file option
unshift @defaults_options, "--defaults-extra-file=$1";
}
}
foreach (@defaults_options)
{
$_ = quote_shell_word($_);
}
# Add [mysqld_multi] options to front of @ARGV, ready for GetOptions()
unshift @ARGV, defaults_for_group('mysqld_multi');
# The --config-file option can be ignored; if passed on the command
# line, it's already handled; if specified in the configuration file,
# it's redundant and not useful
@ARGV= grep { not /^--config-file=/ } @ARGV;
# We've already handled --no-defaults, --defaults-file, etc.
if (!GetOptions("help", "example", "version", "mysqld=s", "mysqladmin=s",
"user=s", "password=s", "log=s", "no-log",
"tcp-ip", "silent", "verbose"))
{
$flag_exit= 1;
}
if (defined($opt_config_file) && !($opt_config_file =~ m/\//))
{
# No path. Use current working directory
$opt_config_file= "./" . $opt_config_file;
}
usage() if ($opt_help);
if ($opt_verbose && $opt_silent)
{
print "Both --verbose and --silent has been given. Some of the warnings ";
print "Both --verbose and --silent have been given. Some of the warnings ";
print "will be disabled\nand some will be enabled.\n\n";
}
@ -168,51 +167,42 @@ sub main
}
}
####
#### Quote option argument. Add double quotes around the argument
#### and escape the following: $, \, "
#### This function is needed, because my_print_defaults drops possible
#### quotes, single or double, from in front of an argument and from
#### the end.
####
#
# Quote word for shell
#
sub quote_opt_arg
sub quote_shell_word
{
my ($option)= @_;
if ($option =~ m/(\-\-[a-zA-Z0-9\_\-]+)=(.*)/)
{
$option= $1;
$arg= $2;
$arg=~ s/\\/\\\\/g; # Escape escape character first to avoid doubling.
$arg=~ s/\$/\\\$/g;
$arg=~ s/\"/\\\"/g;
$arg= "\"" . $arg . "\"";
$option= $option . "=" . $arg;
}
$option =~ s!([^\w=./-])!\\$1!g;
return $option;
}
sub defaults_for_group
{
my ($group) = @_;
return () unless $my_print_defaults_exists;
my $com= join ' ', 'my_print_defaults', @defaults_options, $group;
my @defaults = `$com`;
chomp @defaults;
return @defaults;
}
####
#### Init log file. Check for appropriate place for log file, in the following
#### order my_print_defaults mysqld datadir, @datadir@, /var/log, /tmp
#### order: my_print_defaults mysqld datadir, @datadir@
####
sub init_log
{
if ($my_print_defaults_exists)
foreach my $opt (defaults_for_group('mysqld'))
{
@mysqld_opts= `my_print_defaults mysqld`;
chomp @mysqld_opts;
foreach my $opt (@mysqld_opts)
if ($opt =~ m/^--datadir=(.*)/ && -d "$1" && -w "$1")
{
if ($opt =~ m/^\-\-datadir[=](.*)/)
{
if (-d "$1" && -w "$1")
{
$logdir= $1;
}
}
$logdir= $1;
}
}
if (!defined($logdir))
@ -303,11 +293,7 @@ sub start_mysqlds()
@groups = &find_groups($groupids);
for ($i = 0; defined($groups[$i]); $i++)
{
$com = "my_print_defaults";
$com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
$com.= " $groups[$i]";
@options = `$com`;
chop @options;
@options = defaults_for_group($groups[$i]);
$mysqld_found= 1; # The default
$mysqld_found= 0 if (!length($mysqld));
@ -326,7 +312,7 @@ sub start_mysqlds()
}
else
{
$options[$j]= quote_opt_arg($options[$j]);
$options[$j]= quote_shell_word($options[$j]);
$tmp.= " $options[$j]";
}
}
@ -401,11 +387,7 @@ sub get_mysqladmin_options
my ($i, @groups)= @_;
my ($mysqladmin_found, $com, $tmp, $j);
$com = "my_print_defaults";
$com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
$com.= " $groups[$i]";
@options = `$com`;
chop @options;
@options = defaults_for_group($groups[$i]);
$mysqladmin_found= 1; # The default
$mysqladmin_found= 0 if (!length($mysqladmin));
@ -445,129 +427,81 @@ sub get_mysqladmin_options
return $com;
}
####
#### Find groups. Takes the valid group numbers as an argument, parses
#### them, puts them in the ascending order, removes duplicates and
#### returns the wanted groups accordingly.
####
# Return a list of option files which can be opened. Similar, but not
# identical, to behavior of my_search_option_files()
sub list_defaults_files
{
my %opt;
foreach (@defaults_options)
{
return () if /^--no-defaults$/;
$opt{$1} = $2 if /^--defaults-(extra-file|file)=(.*)$/;
}
return ($opt{file}) if exists $opt{file};
my %seen; # Don't list the same file more than once
return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ }
('/etc/my.cnf',
'/etc/mysql/my.cnf',
'@sysconfdir@/my.cnf',
($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef),
$opt{'extra-file'},
($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef));
}
# Takes a specification of GNRs (see --help), and returns a list of matching
# groups which actually are mentioned in a relevant config file
sub find_groups
{
my ($raw_gids) = @_;
my (@groups, @data, @tmp, $line, $i, $k, @pre_gids, @gids, @tmp2,
$prev_value);
# Read the lines from the config file to variable 'data'
if (defined($opt_config_file))
{
open(MY_CNF, "<$opt_config_file") && (@data=<MY_CNF>) && close(MY_CNF);
}
else
{
if (-f "@sysconfdir@/my.cnf" && -r "@sysconfdir@/my.cnf")
{
open(MY_CNF, "<@sysconfdir@/my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF);
} elsif (-f "/etc/my.cnf" && -r "/etc/my.cnf")
{
open(MY_CNF, "</etc/my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF);
}
for ($i = 0; ($line = shift @tmp); $i++)
{
$data[$i] = $line;
}
if (-f "/etc/mysql/my.cnf" && -r "/etc/mysql/my.cnf")
{
open(MY_CNF, "</etc/mysql/my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF);
}
for (; ($line = shift @tmp); $i++)
{
$data[$i] = $line;
}
if (defined($ENV{MYSQL_HOME}) && -f "$ENV{MYSQL_HOME}/my.cnf" &&
-r "$ENV{MYSQL_HOME}/my.cnf")
{
open(MY_CNF, "<$ENV{MYSQL_HOME}/my.cnf") && (@tmp=<MY_CNF>) &&
close(MY_CNF);
}
for (; ($line = shift @tmp); $i++)
{
$data[$i] = $line;
}
if (-f "$homedir/.my.cnf" && -r "$homedir/.my.cnf")
{
open(MY_CNF, "<$homedir/.my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF);
}
for (; ($line = shift @tmp); $i++)
{
$data[$i] = $line;
}
}
chomp @data;
# Make a list of the wanted group ids
my %gids;
my @groups;
if (defined($raw_gids))
{
@pre_gids = split(',', $raw_gids);
}
if (defined($raw_gids))
{
for ($i = 0, $j = 0; defined($pre_gids[$i]); $i++)
# Make a hash of the wanted group ids
foreach my $raw_gid (split ',', $raw_gids)
{
if ($pre_gids[$i] =~ m/^(\d+)$/)
# Match 123 or 123-456
my ($start, $end) = ($raw_gid =~ /^\s*(\d+)(?:\s*-\s*(\d+))?\s*$/);
$end = $start if not defined $end;
if (not defined $start or $end < $start or $start < 0)
{
$gids[$j] = $1;
$j++;
print "ABORT: Bad GNR: $raw_gid; see $my_progname --help\n";
exit(1);
}
elsif ($pre_gids[$i] =~ m/^(\d+)(\-)(\d+)$/)
foreach my $i ($start .. $end)
{
for ($k = $1; $k <= $3; $k++)
{
$gids[$j] = $k;
$j++;
}
}
else
{
print "ABORT: Bad GNR: $pre_gids[$i] See $my_progname --help\n";
exit(1);
# Use $i + 0 to normalize numbers (002 + 0 -> 2)
$gids{$i + 0}= 1;
}
}
}
# Sort the list of gids numerically in ascending order
@gids = sort {$a <=> $b} @gids;
# Remove non-positive integers and duplicates
for ($i = 0, $j = 0; defined($gids[$i]); $i++)
my @defaults_files = list_defaults_files();
#warn "@{[sort keys %gids]} -> @defaults_files\n";
foreach my $file (@defaults_files)
{
next if ($gids[$i] <= 0);
if (!$i || $prev_value != $gids[$i])
next unless open CONF, "< $file";
while (<CONF>)
{
$tmp2[$j] = $gids[$i];
$j++;
}
$prev_value = $gids[$i];
}
@gids = @tmp2;
# Find and return the wanted groups
for ($i = 0, $j = 0; defined($data[$i]); $i++)
{
if ($data[$i] =~ m/^(\s*\[\s*)(mysqld)(\d+)(\s*\]\s*)$/)
{
if (defined($raw_gids))
if (/^\s*\[\s*(mysqld)(\d+)\s*\]\s*$/)
{
for ($k = 0; defined($gids[$k]); $k++)
{
if ($gids[$k] == $3)
{
$groups[$j] = $2 . $3;
$j++;
}
}
}
else
{
$groups[$j] = $2 . $3;
$j++;
#warn "Found a group: $1$2\n";
# Use $2 + 0 to normalize numbers (002 + 0 -> 2)
if (not defined($raw_gids) or $gids{$2 + 0})
{
push @groups, "$1$2";
}
}
}
close CONF;
}
return @groups;
}
@ -806,8 +740,16 @@ groups found will either be started, stopped, or reported. Note that
syntax for specifying GNRs must appear without spaces.
Options:
--config-file=... Alternative config file.
Using: $opt_config_file
These options must be given before any others:
--no-defaults Do not read any defaults file
--defaults-file=... Read only this configuration file, do not read the
standard system-wide and user-specific files
--defaults-extra-file=... Read this configuration file in addition to the
standard system-wide and user-specific files
Using: @{[join ' ', @defaults_options]}
--config-file=... Deprecated, please use --defaults-extra-file instead
--example Give an example of a config file with extra information.
--help Print this help and exit.
--log=... Log file. Full path to and the name for the log file. NOTE:

View file

@ -6221,6 +6221,15 @@ uint Field_string::max_packed_col_length(uint max_length)
return (max_length > 255 ? 2 : 1)+max_length;
}
uint Field_string::get_key_image(char *buff, uint length, imagetype type_arg)
{
uint bytes = my_charpos(field_charset, ptr, ptr + field_length,
length / field_charset->mbmaxlen);
memcpy(buff, ptr, bytes);
if (bytes < length)
bzero(buff + bytes, length - bytes);
return bytes;
}
Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table,
bool keep_type)
@ -6672,9 +6681,7 @@ uint Field_varstring::max_packed_col_length(uint max_length)
return (max_length > 255 ? 2 : 1)+max_length;
}
void Field_varstring::get_key_image(char *buff, uint length,
imagetype type_arg)
uint Field_varstring::get_key_image(char *buff, uint length, imagetype type)
{
uint f_length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr);
uint local_char_length= length / field_charset->mbmaxlen;
@ -6693,6 +6700,7 @@ void Field_varstring::get_key_image(char *buff, uint length,
*/
bzero(buff+HA_KEY_BLOB_LENGTH+f_length, (length-f_length));
}
return HA_KEY_BLOB_LENGTH+f_length;
}
@ -7064,7 +7072,7 @@ int Field_blob::cmp_binary(const char *a_ptr, const char *b_ptr,
/* The following is used only when comparing a key */
void Field_blob::get_key_image(char *buff, uint length, imagetype type_arg)
uint Field_blob::get_key_image(char *buff,uint length, imagetype type_arg)
{
uint32 blob_length= get_length(ptr);
char *blob;
@ -7076,16 +7084,17 @@ void Field_blob::get_key_image(char *buff, uint length, imagetype type_arg)
MBR mbr;
Geometry_buffer buffer;
Geometry *gobj;
const uint image_length= SIZEOF_STORED_DOUBLE*4;
if (blob_length < SRID_SIZE)
{
bzero(buff, SIZEOF_STORED_DOUBLE*4);
return;
bzero(buff, image_length);
return image_length;
}
get_ptr(&blob);
gobj= Geometry::construct(&buffer, blob, blob_length);
if (!gobj || gobj->get_mbr(&mbr, &dummy))
bzero(buff, SIZEOF_STORED_DOUBLE*4);
bzero(buff, image_length);
else
{
float8store(buff, mbr.xmin);
@ -7093,7 +7102,7 @@ void Field_blob::get_key_image(char *buff, uint length, imagetype type_arg)
float8store(buff+16, mbr.ymin);
float8store(buff+24, mbr.ymax);
}
return;
return image_length;
}
#endif /*HAVE_SPATIAL*/
@ -7114,6 +7123,7 @@ void Field_blob::get_key_image(char *buff, uint length, imagetype type_arg)
}
int2store(buff,length);
memcpy(buff+HA_KEY_BLOB_LENGTH, blob, length);
return HA_KEY_BLOB_LENGTH+length;
}
@ -7399,7 +7409,7 @@ uint Field_blob::max_packed_col_length(uint max_length)
#ifdef HAVE_SPATIAL
void Field_geom::get_key_image(char *buff, uint length, imagetype type_arg)
uint Field_geom::get_key_image(char *buff, uint length, imagetype type)
{
char *blob;
const char *dummy;
@ -7407,16 +7417,17 @@ void Field_geom::get_key_image(char *buff, uint length, imagetype type_arg)
ulong blob_length= get_length(ptr);
Geometry_buffer buffer;
Geometry *gobj;
const uint image_length= SIZEOF_STORED_DOUBLE*4;
if (blob_length < SRID_SIZE)
{
bzero(buff, SIZEOF_STORED_DOUBLE*4);
return;
bzero(buff, image_length);
return image_length;
}
get_ptr(&blob);
gobj= Geometry::construct(&buffer, blob, blob_length);
if (!gobj || gobj->get_mbr(&mbr, &dummy))
bzero(buff, SIZEOF_STORED_DOUBLE*4);
bzero(buff, image_length);
else
{
float8store(buff, mbr.xmin);
@ -7424,6 +7435,7 @@ void Field_geom::get_key_image(char *buff, uint length, imagetype type_arg)
float8store(buff + 16, mbr.ymin);
float8store(buff + 24, mbr.ymax);
}
return image_length;
}
@ -8132,7 +8144,7 @@ int Field_bit::cmp_offset(uint row_offset)
}
void Field_bit::get_key_image(char *buff, uint length, imagetype type_arg)
uint Field_bit::get_key_image(char *buff, uint length, imagetype type_arg)
{
if (bit_len)
{
@ -8140,7 +8152,9 @@ void Field_bit::get_key_image(char *buff, uint length, imagetype type_arg)
*buff++= bits;
length--;
}
memcpy(buff, ptr, min(length, bytes_in_rec));
uint data_length = min(length, bytes_in_rec);
memcpy(buff, ptr, data_length);
return data_length + 1;
}

View file

@ -235,8 +235,39 @@ public:
{ memcpy(buff,ptr,length); }
inline void set_image(char *buff,uint length, CHARSET_INFO *cs)
{ memcpy(ptr,buff,length); }
virtual void get_key_image(char *buff, uint length, imagetype type_arg)
{ get_image(buff,length, &my_charset_bin); }
/*
Copy a field part into an output buffer.
SYNOPSIS
Field::get_key_image()
buff [out] output buffer
length output buffer size
type itMBR for geometry blobs, otherwise itRAW
DESCRIPTION
This function makes a copy of field part of size equal to or
less than "length" parameter value.
For fields of string types (CHAR, VARCHAR, TEXT) the rest of buffer
is padded by zero byte.
NOTES
For variable length character fields (i.e. UTF-8) the "length"
parameter means a number of output buffer bytes as if all field
characters have maximal possible size (mbmaxlen). In the other words,
"length" parameter is a number of characters multiplied by
field_charset->mbmaxlen.
RETURN
Number of copied bytes (excluding padded zero bytes -- see above).
*/
virtual uint get_key_image(char *buff, uint length, imagetype type)
{
get_image(buff, length, &my_charset_bin);
return length;
}
virtual void set_key_image(char *buff,uint length)
{ set_image(buff,length, &my_charset_bin); }
inline longlong val_int_offset(uint row_offset)
@ -1071,6 +1102,7 @@ public:
bool has_charset(void) const
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type);
virtual uint get_key_image(char *buff,uint length, imagetype type);
};
@ -1122,7 +1154,7 @@ public:
my_decimal *val_decimal(my_decimal *);
int cmp(const char *,const char*);
void sort_string(char *buff,uint length);
void get_key_image(char *buff,uint length, imagetype type);
uint get_key_image(char *buff,uint length, imagetype type);
void set_key_image(char *buff,uint length);
void sql_type(String &str) const;
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
@ -1227,7 +1259,7 @@ public:
store_length(length);
memcpy_fixed(ptr+packlength,&data,sizeof(char*));
}
void get_key_image(char *buff,uint length, imagetype type);
uint get_key_image(char *buff,uint length, imagetype type);
void set_key_image(char *buff,uint length);
void sql_type(String &str) const;
inline bool copy()
@ -1285,7 +1317,7 @@ public:
int store(double nr);
int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *);
void get_key_image(char *buff,uint length,imagetype type);
uint get_key_image(char *buff,uint length,imagetype type);
uint size_of() const { return sizeof(*this); }
int reset(void) { return !maybe_null() || Field_blob::reset(); }
};
@ -1395,7 +1427,7 @@ public:
int cmp_offset(uint row_offset);
int cmp_binary_offset(uint row_offset)
{ return cmp_offset(row_offset); }
void get_key_image(char *buff, uint length, imagetype type);
uint get_key_image(char *buff, uint length, imagetype type);
void set_key_image(char *buff, uint length)
{ Field_bit::store(buff, length, &my_charset_bin); }
void sort_string(char *buff, uint length)

View file

@ -3299,6 +3299,8 @@ no_commit:
if (error == DB_DUPLICATE_KEY && auto_inc_used
&& (user_thd->lex->sql_command == SQLCOM_REPLACE
|| user_thd->lex->sql_command == SQLCOM_REPLACE_SELECT
|| (user_thd->lex->sql_command == SQLCOM_INSERT
&& user_thd->lex->duplicates == DUP_UPDATE)
|| (user_thd->lex->sql_command == SQLCOM_LOAD
&& user_thd->lex->duplicates == DUP_REPLACE))) {

View file

@ -1630,6 +1630,34 @@ bool ha_ndbcluster::check_all_operations_for_error(NdbTransaction *trans,
DBUG_RETURN(true);
}
/**
* Check if record contains any null valued columns that are part of a key
*/
static
int
check_null_in_record(const KEY* key_info, const byte *record)
{
KEY_PART_INFO *curr_part, *end_part;
curr_part= key_info->key_part;
end_part= curr_part + key_info->key_parts;
while (curr_part != end_part)
{
if (curr_part->null_bit &&
(record[curr_part->null_offset] & curr_part->null_bit))
return 1;
curr_part++;
}
return 0;
/*
We could instead pre-compute a bitmask in table_share with one bit for
every null-bit in the key, and so check this just by OR'ing the bitmask
with the null bitmap in the record.
But not sure it's worth it.
*/
}
/*
* Peek to check if any rows already exist with conflicting
* primary key or unique index values
@ -1671,7 +1699,17 @@ int ha_ndbcluster::peek_indexed_rows(const byte *record, bool check_pk)
if (i != table->s->primary_key &&
key_info->flags & HA_NOSAME)
{
// A unique index is defined on table
/*
A unique index is defined on table.
We cannot look up a NULL field value in a unique index. But since
keys with NULLs are not indexed, such rows cannot conflict anyway, so
we just skip the index in this case.
*/
if (check_null_in_record(key_info, record))
{
DBUG_PRINT("info", ("skipping check for key with NULL"));
continue;
}
NdbIndexOperation *iop;
NDBINDEX *unique_index = (NDBINDEX *) m_index[i].unique_index;
key_part= key_info->key_part;
@ -2816,7 +2854,7 @@ int ha_ndbcluster::index_end()
}
/**
* Check if key contains null
* Check if key contains nullable columns
*/
static
int

View file

@ -3521,9 +3521,13 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
select->inner_refs_list.push_back(rf);
rf->in_sum_func= thd->lex->in_sum_func;
}
/*
A reference is resolved to a nest level that's outer or the same as
the nest level of the enclosing set function : adjust the value of
max_arg_level for the function if it's needed.
*/
if (thd->lex->in_sum_func &&
thd->lex->in_sum_func->nest_level ==
thd->lex->current_select->nest_level)
thd->lex->in_sum_func->nest_level >= select->nest_level)
{
Item::Type ref_type= (*reference)->type();
set_if_bigger(thd->lex->in_sum_func->max_arg_level,
@ -4158,6 +4162,21 @@ enum_field_types Item::field_type() const
}
bool Item::is_datetime()
{
switch (field_type())
{
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
return TRUE;
default:
break;
}
return FALSE;
}
/*
Create a field to hold a string value from an item
@ -5174,6 +5193,16 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
thd->change_item_tree(reference, fld);
mark_as_dependent(thd, last_checked_context->select_lex,
thd->lex->current_select, this, fld);
/*
A reference is resolved to a nest level that's outer or the same as
the nest level of the enclosing set function : adjust the value of
max_arg_level for the function if it's needed.
*/
if (thd->lex->in_sum_func &&
thd->lex->in_sum_func->nest_level >=
last_checked_context->select_lex->nest_level)
set_if_bigger(thd->lex->in_sum_func->max_arg_level,
last_checked_context->select_lex->nest_level);
return FALSE;
}
if (ref == 0)
@ -5187,6 +5216,16 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
DBUG_ASSERT(*ref && (*ref)->fixed);
mark_as_dependent(thd, last_checked_context->select_lex,
context->select_lex, this, this);
/*
A reference is resolved to a nest level that's outer or the same as
the nest level of the enclosing set function : adjust the value of
max_arg_level for the function if it's needed.
*/
if (thd->lex->in_sum_func &&
thd->lex->in_sum_func->nest_level >=
last_checked_context->select_lex->nest_level)
set_if_bigger(thd->lex->in_sum_func->max_arg_level,
last_checked_context->select_lex->nest_level);
}
}
@ -6118,6 +6157,14 @@ void Item_cache_int::store(Item *item)
}
void Item_cache_int::store(Item *item, longlong val_arg)
{
value= val_arg;
null_value= item->null_value;
unsigned_flag= item->unsigned_flag;
}
String *Item_cache_int::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);

View file

@ -847,6 +847,7 @@ public:
representation is more precise than the string one).
*/
virtual bool result_as_longlong() { return FALSE; }
bool is_datetime();
};
@ -2424,11 +2425,13 @@ public:
Item_cache_int(): Item_cache(), value(0) {}
void store(Item *item);
void store(Item *item, longlong val_arg);
double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; }
longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type() const { return INT_RESULT; }
bool result_as_longlong() { return TRUE; }
};

View file

@ -381,7 +381,9 @@ void Item_bool_func2::fix_length_and_dec()
if (arg_real_item->type() == FIELD_ITEM)
{
Field *field=((Item_field*) arg_real_item)->field;
if (field->can_be_compared_as_longlong())
if (field->can_be_compared_as_longlong() &&
!(arg_real_item->is_datetime() &&
args[1]->result_type() == STRING_RESULT))
{
if (convert_constant_item(thd, field,&args[1]))
{
@ -396,7 +398,9 @@ void Item_bool_func2::fix_length_and_dec()
if (arg_real_item->type() == FIELD_ITEM)
{
Field *field=((Item_field*) arg_real_item)->field;
if (field->can_be_compared_as_longlong())
if (field->can_be_compared_as_longlong() &&
!(arg_real_item->is_datetime() &&
args[0]->result_type() == STRING_RESULT))
{
if (convert_constant_item(thd, field,&args[0]))
{
@ -515,6 +519,334 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type)
}
/*
Convert date provided in a string to the int representation.
SYNOPSIS
get_date_from_str()
thd Thread handle
str a string to convert
warn_type type of the timestamp for issuing the warning
warn_name field name for issuing the warning
error_arg [out] TRUE if string isn't a DATETIME or clipping occur
DESCRIPTION
Convert date provided in the string str to the int representation.
if the string contains wrong date or doesn't contain it at all
then the warning is issued and TRUE returned in the error_arg argument.
The warn_type and the warn_name arguments are used as the name and the
type of the field when issuing the warning.
RETURN
converted value.
*/
static ulonglong
get_date_from_str(THD *thd, String *str, timestamp_type warn_type,
char *warn_name, bool *error_arg)
{
ulonglong value= 0;
int error;
MYSQL_TIME l_time;
enum_mysql_timestamp_type ret;
*error_arg= TRUE;
ret= str_to_datetime(str->ptr(), str->length(), &l_time,
(TIME_FUZZY_DATE | MODE_INVALID_DATES |
(thd->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE))),
&error);
if ((ret == MYSQL_TIMESTAMP_DATETIME || ret == MYSQL_TIMESTAMP_DATE))
{
value= TIME_to_ulonglong_datetime(&l_time);
*error_arg= FALSE;
}
if (error || *error_arg)
{
make_truncated_value_warning(thd, str->ptr(), str->length(), warn_type,
warn_name);
*error_arg= TRUE;
}
return value;
}
/*
Check whether compare_datetime() can be used to compare items.
SYNOPSIS
Arg_comparator::can_compare_as_dates()
a, b [in] items to be compared
const_value [out] converted value of the string constant, if any
DESCRIPTION
Check several cases when the DATE/DATETIME comparator should be used.
The following cases are checked:
1. Both a and b is a DATE/DATETIME field/function returning string or
int result.
2. Only a or b is a DATE/DATETIME field/function returning string or
int result and the other item (b or a) is an item with string result.
If the second item is a constant one then it's checked to be
convertible to the DATE/DATETIME type. If the constant can't be
converted to a DATE/DATETIME then the compare_datetime() comparator
isn't used and the warning about wrong DATE/DATETIME value is issued.
In all other cases (date-[int|real|decimal]/[int|real|decimal]-date)
the comparison is handled by other comparators.
If the datetime comparator can be used and one the operands of the
comparison is a string constant that was successfully converted to a
DATE/DATETIME type then the result of the conversion is returned in the
const_value if it is provided. If there is no constant or
compare_datetime() isn't applicable then the *const_value remains
unchanged.
RETURN
the found type of date comparison
*/
enum Arg_comparator::enum_date_cmp_type
Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
{
enum enum_date_cmp_type cmp_type= CMP_DATE_DFLT;
Item *str_arg= 0, *date_arg= 0;
if (a->type() == Item::ROW_ITEM || b->type() == Item::ROW_ITEM)
return CMP_DATE_DFLT;
if (a->is_datetime())
{
if (b->is_datetime())
cmp_type= CMP_DATE_WITH_DATE;
else if (b->result_type() == STRING_RESULT)
{
cmp_type= CMP_DATE_WITH_STR;
date_arg= a;
str_arg= b;
}
}
else if (b->is_datetime() && a->result_type() == STRING_RESULT)
{
cmp_type= CMP_STR_WITH_DATE;
date_arg= b;
str_arg= a;
}
if (cmp_type != CMP_DATE_DFLT)
{
if (cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item())
{
THD *thd= current_thd;
ulonglong value;
bool error;
String tmp, *str_val= 0;
timestamp_type t_type= (date_arg->field_type() == MYSQL_TYPE_DATE ?
MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME);
str_val= str_arg->val_str(&tmp);
if (str_arg->null_value)
return CMP_DATE_DFLT;
value= get_date_from_str(thd, str_val, t_type, date_arg->name, &error);
if (error)
return CMP_DATE_DFLT;
if (const_value)
*const_value= value;
}
}
return cmp_type;
}
int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
Item **a1, Item **a2,
Item_result type)
{
enum enum_date_cmp_type cmp_type;
ulonglong const_value;
a= a1;
b= a2;
if ((cmp_type= can_compare_as_dates(*a, *b, &const_value)))
{
thd= current_thd;
owner= owner_arg;
a_type= (*a)->field_type();
b_type= (*b)->field_type();
a_cache= 0;
b_cache= 0;
if (cmp_type != CMP_DATE_WITH_DATE &&
((*b)->const_item() || (*a)->const_item()))
{
Item_cache_int *cache= new Item_cache_int();
/* Mark the cache as non-const to prevent re-caching. */
cache->set_used_tables(1);
if (!(*a)->is_datetime())
{
cache->store((*a), const_value);
a_cache= cache;
a= (Item **)&a_cache;
}
else
{
cache->store((*b), const_value);
b_cache= cache;
b= (Item **)&b_cache;
}
}
is_nulls_eq= test(owner && owner->functype() == Item_func::EQUAL_FUNC);
func= &Arg_comparator::compare_datetime;
return 0;
}
return set_compare_func(owner_arg, type);
}
void Arg_comparator::set_datetime_cmp_func(Item **a1, Item **b1)
{
thd= current_thd;
/* A caller will handle null values by itself. */
owner= NULL;
a= a1;
b= b1;
a_type= (*a)->field_type();
b_type= (*b)->field_type();
a_cache= 0;
b_cache= 0;
is_nulls_eq= FALSE;
func= &Arg_comparator::compare_datetime;
}
/*
Retrieves correct DATETIME value from given item.
SYNOPSIS
get_datetime_value()
thd thread handle
item_arg [in/out] item to retrieve DATETIME value from
cache_arg [in/out] pointer to place to store the caching item to
warn_item [in] item for issuing the conversion warning
is_null [out] TRUE <=> the item_arg is null
DESCRIPTION
Retrieves the correct DATETIME value from given item for comparison by the
compare_datetime() function.
If item's result can be compared as longlong then its int value is used
and its string value is used otherwise. Strings are always parsed and
converted to int values by the get_date_from_str() function.
This allows us to compare correctly string dates with missed insignificant
zeros. If an item is a constant one then its value is cached and it isn't
get parsed again. An Item_cache_int object is used for caching values. It
seamlessly substitutes the original item. The cache item is marked as
non-constant to prevent re-caching it again. In order to compare
correctly DATE and DATETIME items the result of the former are treated as
a DATETIME with zero time (00:00:00).
RETURN
obtained value
*/
static ulonglong
get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
Item *warn_item, bool *is_null)
{
ulonglong value= 0;
String buf, *str= 0;
Item *item= **item_arg;
if (item->result_as_longlong())
{
value= item->val_int();
*is_null= item->null_value;
if (item->field_type() == MYSQL_TYPE_DATE)
value*= 1000000L;
}
else
{
str= item->val_str(&buf);
*is_null= item->null_value;
}
if (*is_null)
return -1;
/*
Convert strings to the integer DATE/DATETIME representation.
Even if both dates provided in strings we can't compare them directly as
strings as there is no warranty that they are correct and do not miss
some insignificant zeros.
*/
if (str)
{
bool error;
enum_field_types f_type= warn_item->field_type();
timestamp_type t_type= f_type ==
MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME;
value= get_date_from_str(thd, str, t_type, warn_item->name, &error);
}
if (item->const_item())
{
Item_cache_int *cache= new Item_cache_int();
/* Mark the cache as non-const to prevent re-caching. */
cache->set_used_tables(1);
cache->store(item, value);
*cache_arg= cache;
*item_arg= cache_arg;
}
return value;
}
/*
Compare items values as dates.
SYNOPSIS
Arg_comparator::compare_datetime()
DESCRIPTION
Compare items values as DATE/DATETIME for both EQUAL_FUNC and from other
comparison functions. The correct DATETIME values are obtained
with help of the get_datetime_value() function.
RETURN
If is_nulls_eq is TRUE:
1 if items are equal or both are null
0 otherwise
If is_nulls_eq is FALSE:
-1 a < b or one of items is null
0 a == b
1 a > b
*/
int Arg_comparator::compare_datetime()
{
bool is_null= FALSE;
ulonglong a_value, b_value;
/* Get DATE/DATETIME value of the 'a' item. */
a_value= get_datetime_value(thd, &a, &a_cache, *b, &is_null);
if (!is_nulls_eq && is_null)
{
if (owner)
owner->null_value= 1;
return -1;
}
/* Get DATE/DATETIME value of the 'b' item. */
b_value= get_datetime_value(thd, &b, &b_cache, *a, &is_null);
if (is_null)
{
if (owner)
owner->null_value= is_nulls_eq ? 0 : 1;
return is_nulls_eq ? 1 : -1;
}
if (owner)
owner->null_value= 0;
/* Compare values. */
if (is_nulls_eq)
return (a_value == b_value);
return a_value < b_value ? -1 : (a_value > b_value ? 1 : 0);
}
int Arg_comparator::compare_string()
{
String *res1,*res2;
@ -1361,8 +1693,11 @@ bool Item_func_between::fix_fields(THD *thd, Item **ref)
void Item_func_between::fix_length_and_dec()
{
max_length= 1;
THD *thd= current_thd;
max_length= 1;
THD *thd= current_thd;
int i;
bool datetime_found= FALSE;
compare_as_dates= TRUE;
/*
As some compare functions are generated after sql_yacc,
@ -1377,26 +1712,29 @@ void Item_func_between::fix_length_and_dec()
return;
/*
Make a special case of compare with date/time and longlong fields.
They are compared as integers, so for const item this time-consuming
conversion can be done only once, not for every single comparison
Detect the comparison of DATE/DATETIME items.
At least one of items should be a DATE/DATETIME item and other items
should return the STRING result.
*/
if (args[0]->real_item()->type() == FIELD_ITEM &&
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE)
for (i= 0; i < 3; i++)
{
Field *field=((Item_field*) (args[0]->real_item()))->field;
if (field->can_be_compared_as_longlong())
if (args[i]->is_datetime())
{
/*
The following can't be recoded with || as convert_constant_item
changes the argument
*/
if (convert_constant_item(thd, field,&args[1]))
cmp_type=INT_RESULT; // Works for all types.
if (convert_constant_item(thd, field,&args[2]))
cmp_type=INT_RESULT; // Works for all types.
datetime_found= TRUE;
continue;
}
if (args[i]->result_type() == STRING_RESULT)
continue;
compare_as_dates= FALSE;
break;
}
if (!datetime_found)
compare_as_dates= FALSE;
if (compare_as_dates)
{
ge_cmp.set_datetime_cmp_func(args, args + 1);
le_cmp.set_datetime_cmp_func(args, args + 2);
}
}
@ -1404,7 +1742,27 @@ void Item_func_between::fix_length_and_dec()
longlong Item_func_between::val_int()
{ // ANSI BETWEEN
DBUG_ASSERT(fixed == 1);
if (cmp_type == STRING_RESULT)
if (compare_as_dates)
{
int ge_res, le_res;
ge_res= ge_cmp.compare();
if ((null_value= args[0]->null_value))
return 0;
le_res= le_cmp.compare();
if (!args[1]->null_value && !args[2]->null_value)
return (longlong) ((ge_res >= 0 && le_res <=0) != negated);
else if (args[1]->null_value)
{
null_value= le_res > 0; // not null if false range.
}
else
{
null_value= ge_res < 0;
}
}
else if (cmp_type == STRING_RESULT)
{
String *value,*a,*b;
value=args[0]->val_str(&value0);

View file

@ -35,12 +35,19 @@ class Arg_comparator: public Sql_alloc
Item_bool_func2 *owner;
Arg_comparator *comparators; // used only for compare_row()
double precision;
/* Fields used in DATE/DATETIME comparison. */
THD *thd;
enum_field_types a_type, b_type; // Types of a and b items
Item *a_cache, *b_cache; // Cached values of a and b items
bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
public:
DTCollation cmp_collation;
Arg_comparator() {};
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2) {};
Arg_comparator(): thd(0), a_cache(0), b_cache(0) {};
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), thd(0),
a_cache(0), b_cache(0) {};
int set_compare_func(Item_bool_func2 *owner, Item_result type);
inline int set_compare_func(Item_bool_func2 *owner_arg)
@ -48,14 +55,10 @@ public:
return set_compare_func(owner_arg, item_cmp_type((*a)->result_type(),
(*b)->result_type()));
}
inline int set_cmp_func(Item_bool_func2 *owner_arg,
int set_cmp_func(Item_bool_func2 *owner_arg,
Item **a1, Item **a2,
Item_result type)
{
a= a1;
b= a2;
return set_compare_func(owner_arg, type);
}
Item_result type);
inline int set_cmp_func(Item_bool_func2 *owner_arg,
Item **a1, Item **a2)
{
@ -83,7 +86,12 @@ public:
int compare_e_row(); // compare args[0] & args[1]
int compare_real_fixed();
int compare_e_real_fixed();
int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
static enum enum_date_cmp_type can_compare_as_dates(Item *a, Item *b,
ulonglong *const_val_arg);
void set_datetime_cmp_func(Item **a1, Item **b1);
static arg_cmp_func comparator_matrix [5][2];
friend class Item_func;
@ -572,8 +580,12 @@ class Item_func_between :public Item_func_opt_neg
public:
Item_result cmp_type;
String value0,value1,value2;
/* TRUE <=> arguments will be compared as dates. */
bool compare_as_dates;
/* Comparators used for DATE/DATETIME comparison. */
Arg_comparator ge_cmp, le_cmp;
Item_func_between(Item *a, Item *b, Item *c)
:Item_func_opt_neg(a, b, c) {}
:Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) {}
longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
enum Functype functype() const { return BETWEEN; }

View file

@ -616,6 +616,14 @@ Item *Item_func::get_tmp_table_item(THD *thd)
return copy_or_same(thd);
}
double Item_int_func::val_real()
{
DBUG_ASSERT(fixed == 1);
return unsigned_flag ? (double) ((ulonglong) val_int()) : (double) val_int();
}
String *Item_int_func::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@ -804,7 +812,10 @@ double Item_func_numhybrid::val_real()
return result;
}
case INT_RESULT:
return (double)int_op();
{
longlong result= int_op();
return unsigned_flag ? (double) ((ulonglong) result) : (double) result;
}
case REAL_RESULT:
return real_op();
case STRING_RESULT:
@ -1341,6 +1352,8 @@ longlong Item_func_mod::int_op()
DBUG_ASSERT(fixed == 1);
longlong value= args[0]->val_int();
longlong val2= args[1]->val_int();
longlong result;
if ((null_value= args[0]->null_value || args[1]->null_value))
return 0; /* purecov: inspected */
if (val2 == 0)
@ -1350,9 +1363,13 @@ longlong Item_func_mod::int_op()
}
if (args[0]->unsigned_flag)
return ((ulonglong) value) % val2;
result= args[1]->unsigned_flag ?
((ulonglong) value) % ((ulonglong) val2) : ((ulonglong) value) % val2;
else
result= args[1]->unsigned_flag ?
value % ((ulonglong) val2) : value % val2;
return value % val2;
return result;
}
double Item_func_mod::real_op()
@ -1407,6 +1424,7 @@ void Item_func_mod::fix_length_and_dec()
{
Item_num_op::fix_length_and_dec();
maybe_null= 1;
unsigned_flag= args[0]->unsigned_flag;
}
@ -1485,8 +1503,9 @@ double Item_func_abs::real_op()
longlong Item_func_abs::int_op()
{
longlong value= args[0]->val_int();
null_value= args[0]->null_value;
return value >= 0 ? value : -value;
if ((null_value= args[0]->null_value))
return 0;
return (value >= 0) || unsigned_flag ? value : -value;
}
@ -1507,6 +1526,7 @@ my_decimal *Item_func_abs::decimal_op(my_decimal *decimal_value)
void Item_func_abs::fix_length_and_dec()
{
Item_func_num1::fix_length_and_dec();
unsigned_flag= args[0]->unsigned_flag;
}
@ -1881,6 +1901,10 @@ my_decimal *Item_func_floor::decimal_op(my_decimal *decimal_value)
void Item_func_round::fix_length_and_dec()
{
int decimals_to_set;
longlong val1;
bool val1_unsigned;
unsigned_flag= args[0]->unsigned_flag;
if (!args[1]->const_item())
{
@ -1889,8 +1913,14 @@ void Item_func_round::fix_length_and_dec()
hybrid_type= REAL_RESULT;
return;
}
int decimals_to_set= max((int)args[1]->val_int(), 0);
val1= args[1]->val_int();
val1_unsigned= args[1]->unsigned_flag;
if (val1 < 0)
decimals_to_set= val1_unsigned ? INT_MAX : 0;
else
decimals_to_set= (val1 > INT_MAX) ? INT_MAX : (int) val1;
if (args[0]->decimals == NOT_FIXED_DEC)
{
max_length= args[0]->max_length;
@ -1907,10 +1937,9 @@ void Item_func_round::fix_length_and_dec()
max_length= float_length(decimals);
break;
case INT_RESULT:
if (!decimals_to_set &&
(truncate || (args[0]->decimal_precision() < DECIMAL_LONGLONG_DIGITS)))
if ((!decimals_to_set && truncate) || (args[0]->decimal_precision() < DECIMAL_LONGLONG_DIGITS))
{
int length_can_increase= test(!truncate && (args[1]->val_int() < 0));
int length_can_increase= test(!truncate && (val1 < 0) && !val1_unsigned);
max_length= args[0]->max_length + length_can_increase;
/* Here we can keep INT_RESULT */
hybrid_type= INT_RESULT;
@ -1936,10 +1965,12 @@ void Item_func_round::fix_length_and_dec()
}
}
double my_double_round(double value, int dec, bool truncate)
double my_double_round(double value, longlong dec, bool dec_unsigned,
bool truncate)
{
double tmp;
uint abs_dec= abs(dec);
bool dec_negative= (dec < 0) && !dec_unsigned;
ulonglong abs_dec= dec_negative ? -dec : dec;
/*
tmp2 is here to avoid return the value with 80 bit precision
This will fix that the test round(0.1,1) = round(0.1,1) is true
@ -1949,7 +1980,11 @@ double my_double_round(double value, int dec, bool truncate)
tmp=(abs_dec < array_elements(log_10) ?
log_10[abs_dec] : pow(10.0,(double) abs_dec));
if (truncate)
if (dec_negative && isinf(tmp))
tmp2= 0;
else if (!dec_negative && isinf(value * tmp))
tmp2= value;
else if (truncate)
{
if (value >= 0)
tmp2= dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp;
@ -1965,24 +2000,35 @@ double my_double_round(double value, int dec, bool truncate)
double Item_func_round::real_op()
{
double value= args[0]->val_real();
int dec= (int) args[1]->val_int();
if (!(null_value= args[0]->null_value || args[1]->null_value))
return my_double_round(value, dec, truncate);
return my_double_round(value, args[1]->val_int(), args[1]->unsigned_flag,
truncate);
return 0.0;
}
/*
Rounds a given value to a power of 10 specified as the 'to' argument,
avoiding overflows when the value is close to the ulonglong range boundary.
*/
static inline ulonglong my_unsigned_round(ulonglong value, ulonglong to)
{
ulonglong tmp= value / to * to;
return (value - tmp < (to >> 1)) ? tmp : tmp + to;
}
longlong Item_func_round::int_op()
{
longlong value= args[0]->val_int();
int dec=(int) args[1]->val_int();
longlong dec= args[1]->val_int();
decimals= 0;
uint abs_dec;
ulonglong abs_dec;
if ((null_value= args[0]->null_value || args[1]->null_value))
return 0;
if (dec >= 0)
if ((dec >= 0) || args[1]->unsigned_flag)
return value; // integer have not digits after point
abs_dec= -dec;
@ -1994,21 +2040,12 @@ longlong Item_func_round::int_op()
tmp= log_10_int[abs_dec];
if (truncate)
{
if (unsigned_flag)
value= (ulonglong(value)/tmp)*tmp;
else
value= (value/tmp)*tmp;
}
value= (unsigned_flag) ?
((ulonglong) value / tmp) * tmp : (value / tmp) * tmp;
else
{
if (unsigned_flag)
value= ((ulonglong(value)+(tmp>>1))/tmp)*tmp;
else if ( value >= 0)
value= ((value+(tmp>>1))/tmp)*tmp;
else
value= ((value-(tmp>>1))/tmp)*tmp;
}
value= (unsigned_flag || value >= 0) ?
my_unsigned_round((ulonglong) value, tmp) :
-(longlong) my_unsigned_round((ulonglong) -value, tmp);
return value;
}
@ -2016,14 +2053,18 @@ longlong Item_func_round::int_op()
my_decimal *Item_func_round::decimal_op(my_decimal *decimal_value)
{
my_decimal val, *value= args[0]->val_decimal(&val);
int dec=(int) args[1]->val_int();
if (dec > 0)
longlong dec= args[1]->val_int();
if (dec > 0 || (dec < 0 && args[1]->unsigned_flag))
{
decimals= min(dec, DECIMAL_MAX_SCALE); // to get correct output
dec= min((ulonglong) dec, DECIMAL_MAX_SCALE);
decimals= (uint8) dec; // to get correct output
}
else if (dec < INT_MIN)
dec= INT_MIN;
if (!(null_value= (args[0]->null_value || args[1]->null_value ||
my_decimal_round(E_DEC_FATAL_ERROR, value, dec, truncate,
decimal_value) > 1)))
my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
truncate, decimal_value) > 1)))
return decimal_value;
return 0;
}

View file

@ -278,7 +278,7 @@ public:
{ max_length= 21; }
Item_int_func(List<Item> &list) :Item_func(list) { max_length= 21; }
Item_int_func(THD *thd, Item_int_func *item) :Item_func(thd, item) {}
double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
double val_real();
String *val_str(String*str);
enum Item_result result_type () const { return INT_RESULT; }
void fix_length_and_dec() {}
@ -303,12 +303,6 @@ class Item_func_signed :public Item_int_func
public:
Item_func_signed(Item *a) :Item_int_func(a) {}
const char *func_name() const { return "cast_as_signed"; }
double val_real()
{
double tmp= args[0]->val_real();
null_value= args[0]->null_value;
return tmp;
}
longlong val_int();
longlong val_int_from_str(int *error);
void fix_length_and_dec()
@ -719,6 +713,35 @@ public:
};
/*
Objects of this class are used for ROLLUP queries to wrap up
each constant item referred to in GROUP BY list.
*/
class Item_func_rollup_const :public Item_func
{
public:
Item_func_rollup_const(Item *a) :Item_func(a)
{
name= a->name;
name_length= a->name_length;
}
double val_real() { return args[0]->val_real(); }
longlong val_int() { return args[0]->val_int(); }
String *val_str(String *str) { return args[0]->val_str(str); }
my_decimal *val_decimal(my_decimal *dec) { return args[0]->val_decimal(dec); }
const char *func_name() const { return "rollup_const"; }
bool const_item() const { return 0; }
Item_result result_type() const { return args[0]->result_type(); }
void fix_length_and_dec()
{
collation= args[0]->collation;
max_length= args[0]->max_length;
decimals=args[0]->decimals;
}
};
class Item_func_length :public Item_int_func
{
String value;

View file

@ -1995,7 +1995,7 @@ String *Item_func_format::val_str(String *str)
double nr= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */
nr= my_double_round(nr, decimals, FALSE);
nr= my_double_round(nr, (longlong) decimals, FALSE, FALSE);
/* Here default_charset() is right as this is not an automatic conversion */
str->set(nr,decimals, default_charset());
if (isnan(nr))

View file

@ -175,13 +175,25 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
MYF(0));
return TRUE;
}
if (in_sum_func && in_sum_func->nest_level == nest_level)
if (in_sum_func)
{
/*
If the set function is nested adjust the value of
max_sum_func_level for the nesting set function.
We take into account only enclosed set functions that are to be
aggregated on the same level or above of the nest level of
the enclosing set function.
But we must always pass up the max_sum_func_level because it is
the maximum nested level of all directly and indirectly enclosed
set functions. We must do that even for set functions that are
aggregated inside of their enclosing set function's nest level
because the enclosing function may contain another enclosing
function that is to be aggregated outside or on the same level
as its parent's nest level.
*/
set_if_bigger(in_sum_func->max_sum_func_level, aggr_level);
if (in_sum_func->nest_level >= aggr_level)
set_if_bigger(in_sum_func->max_sum_func_level, aggr_level);
set_if_bigger(in_sum_func->max_sum_func_level, max_sum_func_level);
}
update_used_tables();
thd->lex->in_sum_func= in_sum_func;

View file

@ -2173,6 +2173,27 @@ bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date)
default:
goto null_date;
}
/* Adjust cached_field_type according to the detected type. */
if (cached_field_type == MYSQL_TYPE_STRING)
{
switch (ltime->time_type)
{
case MYSQL_TIMESTAMP_DATE:
cached_field_type= MYSQL_TYPE_DATE;
break;
case MYSQL_TIMESTAMP_DATETIME:
cached_field_type= MYSQL_TYPE_DATETIME;
break;
case MYSQL_TIMESTAMP_TIME:
cached_field_type= MYSQL_TYPE_TIME;
break;
default:
/* Shouldn't get here. */
DBUG_ASSERT(0);
break;
}
}
return 0; // Ok
invalid_date:

View file

@ -119,29 +119,22 @@ void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length)
key_length--;
}
}
if (key_part->key_part_flag & HA_BLOB_PART)
{
char *pos;
ulong blob_length= ((Field_blob*) key_part->field)->get_length();
key_length-= HA_KEY_BLOB_LENGTH;
((Field_blob*) key_part->field)->get_ptr(&pos);
length=min(key_length, key_part->length);
set_if_smaller(blob_length, length);
int2store(to_key, (uint) blob_length);
to_key+= HA_KEY_BLOB_LENGTH; // Skip length info
memcpy(to_key, pos, blob_length);
}
else if (key_part->key_part_flag & HA_VAR_LENGTH_PART)
if (key_part->key_part_flag & HA_BLOB_PART ||
key_part->key_part_flag & HA_VAR_LENGTH_PART)
{
key_length-= HA_KEY_BLOB_LENGTH;
length= min(key_length, key_part->length);
key_part->field->get_key_image((char *) to_key, length, Field::itRAW);
key_part->field->get_key_image((char*) to_key, length, Field::itRAW);
to_key+= HA_KEY_BLOB_LENGTH;
}
else
{
length= min(key_length, key_part->length);
memcpy(to_key, from_record + key_part->offset, (size_t) length);
Field *field= key_part->field;
CHARSET_INFO *cs= field->charset();
uint bytes= field->get_key_image((char*) to_key, length, Field::itRAW);
if (bytes < length)
cs->cset->fill(cs, (char*) to_key + bytes, length - bytes, ' ');
}
to_key+= length;
key_length-= length;

View file

@ -1539,7 +1539,8 @@ ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder,
ha_rows max_rows, ha_rows *examined_rows);
void filesort_free_buffers(TABLE *table, bool full);
void change_double_for_sort(double nr,byte *to);
double my_double_round(double value, int dec, bool truncate);
double my_double_round(double value, longlong dec, bool dec_unsigned,
bool truncate);
int get_quick_record(SQL_SELECT *select);
int calc_weekday(long daynr,bool sunday_first_day_of_week);
uint calc_week(TIME *l_time, uint week_behaviour, uint *year);

View file

@ -4588,6 +4588,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
*/
arena= thd->activate_stmt_arena_if_needed(&backup);
thd->lex->current_select->cur_pos_in_select_list= 0;
while (wild_num && (item= it++))
{
if (item->type() == Item::FIELD_ITEM &&
@ -4629,7 +4630,10 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
}
wild_num--;
}
else
thd->lex->current_select->cur_pos_in_select_list++;
}
thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
if (arena)
{
/* make * substituting permanent */
@ -5134,6 +5138,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
item->walk(&Item::reset_query_id_processor,
(byte *)(&thd->query_id));
}
thd->lex->current_select->cur_pos_in_select_list++;
}
/*
In case of stored tables, all fields are considered as used,

View file

@ -5444,8 +5444,9 @@ static void add_not_null_conds(JOIN *join)
for (uint i=join->const_tables ; i < join->tables ; i++)
{
JOIN_TAB *tab=join->join_tab+i;
if ((tab->type == JT_REF || tab->type == JT_REF_OR_NULL) &&
!tab->table->maybe_null)
if ((tab->type == JT_REF || tab->type == JT_EQ_REF ||
tab->type == JT_REF_OR_NULL) &&
!tab->table->maybe_null)
{
for (uint keypart= 0; keypart < tab->ref.key_parts; keypart++)
{
@ -8666,17 +8667,13 @@ static bool
test_if_equality_guarantees_uniqueness(Item *l, Item *r)
{
return r->const_item() &&
/* elements must be of the same result type */
(r->result_type() == l->result_type() ||
/* or dates compared to longs */
(((l->type() == Item::FIELD_ITEM &&
((Item_field *)l)->field->can_be_compared_as_longlong()) ||
(l->type() == Item::FUNC_ITEM &&
((Item_func *)l)->result_as_longlong())) &&
r->result_type() == INT_RESULT))
/* and must have the same collation if compared as strings */
&& (l->result_type() != STRING_RESULT ||
l->collation.collation == r->collation.collation);
/* elements must be compared as dates */
(Arg_comparator::can_compare_as_dates(l, r, 0) ||
/* or of the same result type */
(r->result_type() == l->result_type() &&
/* and must have the same collation if compared as strings */
(l->result_type() != STRING_RESULT ||
l->collation.collation == r->collation.collation)));
}
/*
@ -14543,7 +14540,7 @@ bool JOIN::rollup_init()
for (j=0 ; j < fields_list.elements ; j++)
rollup.fields[i].push_back(rollup.null_items[i]);
}
List_iterator_fast<Item> it(all_fields);
List_iterator<Item> it(all_fields);
Item *item;
while ((item= it++))
{
@ -14556,6 +14553,32 @@ bool JOIN::rollup_init()
{
item->maybe_null= 1;
found_in_group= 1;
if (item->const_item())
{
/*
For ROLLUP queries each constant item referenced in GROUP BY list
is wrapped up into an Item_func object yielding the same value
as the constant item. The objects of the wrapper class are never
considered as constant items and besides they inherit all
properties of the Item_result_field class.
This wrapping allows us to ensure writing constant items
into temporary tables whenever the result of the ROLLUP
operation has to be written into a temporary table, e.g. when
ROLLUP is used together with DISTINCT in the SELECT list.
Usually when creating temporary tables for a intermidiate
result we do not include fields for constant expressions.
*/
Item* new_item= new Item_func_rollup_const(item);
if (!new_item)
return 1;
new_item->fix_fields(thd, (Item **) 0);
thd->change_item_tree(it.ref(), new_item);
for (ORDER *tmp= group_tmp; tmp; tmp= tmp->next)
{
if (*tmp->item == item)
thd->change_item_tree(tmp->item, new_item);
}
}
}
}
if (item->type() == Item::FUNC_ITEM && !found_in_group)

View file

@ -42,6 +42,7 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
static bool prepare_blob_field(THD *thd, create_field *sql_field);
static bool check_engine(THD *thd, const char *table_name,
enum db_type *new_engine);
static void set_tmp_file_path(char *buf, size_t bufsize, THD *thd);
/*
@ -1681,11 +1682,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
/* Check if table exists */
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{
my_snprintf(path, sizeof(path), "%s%s%lx_%lx_%x%s",
mysql_tmpdir, tmp_file_prefix, current_pid, thd->thread_id,
thd->tmp_table++, reg_ext);
if (lower_case_table_names)
my_casedn_str(files_charset_info, path);
set_tmp_file_path(path, sizeof(path), thd);
create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE;
}
else
@ -2801,11 +2798,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
{
if (find_temporary_table(thd, db, table_name))
goto table_exists;
my_snprintf(dst_path, sizeof(dst_path), "%s%s%lx_%lx_%x%s",
mysql_tmpdir, tmp_file_prefix, current_pid,
thd->thread_id, thd->tmp_table++, reg_ext);
if (lower_case_table_names)
my_casedn_str(files_charset_info, dst_path);
set_tmp_file_path(dst_path, sizeof(dst_path), thd);
create_info->table_options|= HA_CREATE_DELAY_KEY_WRITE;
}
else
@ -3316,6 +3309,12 @@ view_err:
create_info->avg_row_length= table->s->avg_row_length;
if (!(used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
create_info->default_table_charset= table->s->table_charset;
if (!(used_fields & HA_CREATE_USED_AUTO) && table->found_next_number_field)
{
/* Table has an autoincrement, copy value to new table */
table->file->info(HA_STATUS_AUTO);
create_info->auto_increment_value= table->file->auto_increment_value;
}
restore_record(table, s->default_values); // Empty record for DEFAULT
List_iterator<Alter_drop> drop_it(alter_info->drop_list);
@ -4313,3 +4312,16 @@ static bool check_engine(THD *thd, const char *table_name,
}
return FALSE;
}
static void set_tmp_file_path(char *buf, size_t bufsize, THD *thd)
{
char *p= strnmov(buf, mysql_tmpdir, bufsize);
my_snprintf(p, bufsize - (p - buf), "%s%lx_%lx_%x%s",
tmp_file_prefix, current_pid,
thd->thread_id, thd->tmp_table++, reg_ext);
if (lower_case_table_names)
{
/* Convert all except tmpdir to lower case */
my_casedn_str(files_charset_info, p);
}
}

View file

@ -1354,19 +1354,18 @@ bool multi_update::send_data(List<Item> &not_used_values)
memcpy((char*) tmp_table->field[0]->ptr,
(char*) table->file->ref, table->file->ref_length);
/* Write row, ignoring duplicated updates to a row */
if ((error= tmp_table->file->write_row(tmp_table->record[0])))
error= tmp_table->file->write_row(tmp_table->record[0]);
if (error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE)
{
if (error != HA_ERR_FOUND_DUPP_KEY &&
error != HA_ERR_FOUND_DUPP_UNIQUE &&
if (error &&
create_myisam_from_heap(thd, tmp_table,
tmp_table_param + offset, error, 1))
{
do_update=0;
DBUG_RETURN(1); // Not a table_is_full error
}
}
else
tmp_table_param + offset, error, 1))
{
do_update= 0;
DBUG_RETURN(1); // Not a table_is_full error
}
found++;
}
}
}
DBUG_RETURN(0);

View file

@ -2670,7 +2670,16 @@ const char *Field_iterator_table::name()
Item *Field_iterator_table::create_item(THD *thd)
{
return new Item_field(thd, &thd->lex->current_select->context, *ptr);
SELECT_LEX *select= thd->lex->current_select;
Item_field *item= new Item_field(thd, &select->context, *ptr);
if (item && thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
!thd->lex->in_sum_func && select->cur_pos_in_select_list != UNDEF_POS)
{
select->non_agg_fields.push_back(item);
item->marker= select->cur_pos_in_select_list;
}
return item;
}

View file

@ -534,7 +534,7 @@ fi
%doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1
%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1*

View file

@ -8785,7 +8785,9 @@ static void test_ts()
int rc, field_count;
char name;
char query[MAX_TEST_QUERY_LENGTH];
const char *queries [3]= {"SELECT a, b, c FROM test_ts WHERE %c=?",
"SELECT a, b, c FROM test_ts WHERE %c=?",
"SELECT a, b, c FROM test_ts WHERE %c=CAST(? AS DATE)"};
myheader("test_ts");
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_ts");
@ -8857,7 +8859,7 @@ static void test_ts()
{
int row_count= 0;
sprintf(query, "SELECT a, b, c FROM test_ts WHERE %c=?", name);
sprintf(query, queries[field_count], name);
if (!opt_silent)
fprintf(stdout, "\n %s", query);

View file

@ -14,7 +14,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
## Process this file with automake to create Makefile.in
EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README \
EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README \
mysql_manifest.cmake create_manifest.js
# Don't update the files from bitkeeper