Commit 4430048e authored by unknown's avatar unknown

Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt

into  magare.gmz:/home/kgeorge/mysql/autopush/B26815-5.0-opt


sql/item_sum.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
parents 456cc52e 08d9d182
...@@ -769,3 +769,14 @@ create table t1 (g geometry not null); ...@@ -769,3 +769,14 @@ create table t1 (g geometry not null);
insert into t1 values(default); insert into t1 values(default);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1; drop table t1;
CREATE TABLE t1 (a GEOMETRY);
CREATE VIEW v1 AS SELECT GeomFromwkb(ASBINARY(a)) FROM t1;
CREATE VIEW v2 AS SELECT a FROM t1;
DESCRIBE v1;
Field Type Null Key Default Extra
GeomFromwkb(ASBINARY(a)) geometry YES NULL
DESCRIBE v2;
Field Type Null Key Default Extra
a geometry YES NULL
DROP VIEW v1,v2;
DROP TABLE t1;
...@@ -717,6 +717,34 @@ d8c4177d225791924.30714720 ...@@ -717,6 +717,34 @@ d8c4177d225791924.30714720
d8c4177d2380fc201.39666693 d8c4177d2380fc201.39666693
d8c4177d24ccef970.14957924 d8c4177d24ccef970.14957924
DROP TABLE t1; DROP TABLE t1;
create table t1 (
c1 char(10), c2 char(10), c3 char(10), c4 char(10),
c5 char(10), c6 char(10), c7 char(10), c8 char(10),
c9 char(10), c10 char(10), c11 char(10), c12 char(10),
c13 char(10), c14 char(10), c15 char(10), c16 char(10),
index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16)
);
insert into t1 (c1) values ('1'),('1'),('1'),('1');
select * from t1 where
c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c11 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c12 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c13 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c14 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c15 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c16 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
;
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16
drop table t1;
End of 4.1 tests End of 4.1 tests
CREATE TABLE t1 ( CREATE TABLE t1 (
id int(11) NOT NULL auto_increment, id int(11) NOT NULL auto_increment,
......
...@@ -3924,3 +3924,26 @@ c a (SELECT GROUP_CONCAT(COUNT(a)+1) FROM t2 WHERE m = a) ...@@ -3924,3 +3924,26 @@ c a (SELECT GROUP_CONCAT(COUNT(a)+1) FROM t2 WHERE m = a)
3 3 4 3 3 4
1 4 2,2 1 4 2,2
DROP table t1,t2; DROP table t1,t2;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
a
1
2
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a;
a
SELECT a FROM t1 t0
WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
a
1
2
SET @@sql_mode='ansi';
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
ERROR HY000: Invalid use of group function
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a;
ERROR HY000: Invalid use of group function
SELECT a FROM t1 t0
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;
...@@ -661,12 +661,6 @@ SELECT * FROM t1 GROUP by t1.a ...@@ -661,12 +661,6 @@ SELECT * FROM t1 GROUP by t1.a
HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c
HAVING MAX(t2.b+t1.a) < 10)); HAVING MAX(t2.b+t1.a) < 10));
a b c a b c
SELECT a, AVG(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b))
AS test FROM t1 GROUP BY a;
a AVG(b) test
1 4.0000 NULL
2 2.0000 k
3 2.5000 NULL
SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c; SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c;
a b c a b c
1 3 c 1 3 c
......
...@@ -479,3 +479,14 @@ create table t1 (g geometry not null); ...@@ -479,3 +479,14 @@ create table t1 (g geometry not null);
insert into t1 values(default); insert into t1 values(default);
drop table t1; drop table t1;
#
# Bug #27300: create view with geometry functions lost columns types
#
CREATE TABLE t1 (a GEOMETRY);
CREATE VIEW v1 AS SELECT GeomFromwkb(ASBINARY(a)) FROM t1;
CREATE VIEW v2 AS SELECT a FROM t1;
DESCRIBE v1;
DESCRIBE v2;
DROP VIEW v1,v2;
DROP TABLE t1;
...@@ -568,6 +568,38 @@ SELECT s.oxid FROM t1 v, t1 s ...@@ -568,6 +568,38 @@ SELECT s.oxid FROM t1 v, t1 s
DROP TABLE t1; DROP TABLE t1;
# BUG#26624 high mem usage (crash) in range optimizer (depends on order of fields in where)
create table t1 (
c1 char(10), c2 char(10), c3 char(10), c4 char(10),
c5 char(10), c6 char(10), c7 char(10), c8 char(10),
c9 char(10), c10 char(10), c11 char(10), c12 char(10),
c13 char(10), c14 char(10), c15 char(10), c16 char(10),
index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16)
);
insert into t1 (c1) values ('1'),('1'),('1'),('1');
# This must run without crash and fast:
select * from t1 where
c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c11 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c12 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c13 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c14 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c15 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
and c16 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh")
;
drop table t1;
--echo End of 4.1 tests --echo End of 4.1 tests
# #
......
...@@ -2782,3 +2782,30 @@ SELECT COUNT(*) c, a, ...@@ -2782,3 +2782,30 @@ SELECT COUNT(*) c, a,
FROM t1 GROUP BY a; FROM t1 GROUP BY a;
DROP table t1,t2; DROP table t1,t2;
#
# Bug #27348: SET FUNCTION used in a subquery from WHERE condition
#
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a;
SELECT a FROM t1 t0
WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
SET @@sql_mode='ansi';
--error 1111
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
--error 1111
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a;
--error 1111
SELECT a FROM t1 t0
WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
SET @@sql_mode=default;
DROP TABLE t1;
...@@ -507,8 +507,9 @@ SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) ...@@ -507,8 +507,9 @@ SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b))
SELECT * FROM t1 GROUP by t1.a SELECT * FROM t1 GROUP by t1.a
HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c
HAVING MAX(t2.b+t1.a) < 10)); HAVING MAX(t2.b+t1.a) < 10));
SELECT a, AVG(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b)) #FIXME: Enable this test after fixing bug #27321
AS test FROM t1 GROUP BY a; #SELECT a, AVG(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b))
# AS test FROM t1 GROUP BY a;
SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c; SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c;
......
...@@ -4275,7 +4275,6 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) ...@@ -4275,7 +4275,6 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table)
case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB: case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_GEOMETRY:
if (this->type() == Item::TYPE_HOLDER) if (this->type() == Item::TYPE_HOLDER)
return new Field_blob(max_length, maybe_null, name, table, return new Field_blob(max_length, maybe_null, name, table,
collation.collation, 1); collation.collation, 1);
...@@ -4283,6 +4282,10 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) ...@@ -4283,6 +4282,10 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table)
return new Field_blob(max_length, maybe_null, name, table, return new Field_blob(max_length, maybe_null, name, table,
collation.collation); collation.collation);
break; // Blob handled outside of case break; // Blob handled outside of case
case MYSQL_TYPE_GEOMETRY:
return new Field_geom(max_length, maybe_null, name, table,
(Field::geometry_type)
((Item_geometry_func *)this)->get_geometry_type());
} }
} }
......
...@@ -149,6 +149,8 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref) ...@@ -149,6 +149,8 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
if (register_sum_func(thd, ref)) if (register_sum_func(thd, ref))
return TRUE; return TRUE;
invalid= aggr_level < 0 && !(allow_sum_func & (1 << nest_level)); invalid= aggr_level < 0 && !(allow_sum_func & (1 << nest_level));
if (!invalid && thd->variables.sql_mode & MODE_ANSI)
invalid= aggr_level < 0 && max_arg_level < nest_level;
} }
if (!invalid && aggr_level < 0) if (!invalid && aggr_level < 0)
{ {
...@@ -164,8 +166,9 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref) ...@@ -164,8 +166,9 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
Additionally we have to check whether possible nested set functions Additionally we have to check whether possible nested set functions
are acceptable here: they are not, if the level of aggregation of are acceptable here: they are not, if the level of aggregation of
some of them is less than aggr_level. some of them is less than aggr_level.
*/ */
invalid= aggr_level <= max_sum_func_level; if (!invalid)
invalid= aggr_level <= max_sum_func_level;
if (invalid) if (invalid)
{ {
my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE), my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
......
***************
*** 177,188 ****
} /* cplusplus */
- #if defined(HAVE_LINUXTHREADS)
- #define THR_KILL_SIGNAL SIGINT
- #else
- #define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads
- #endif
-
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
#include <sys/types.h>
#else
--- 177,182 ----
} /* cplusplus */
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
#include <sys/types.h>
#else
***************
*** 505,510 ****
static void clean_up_mutexes(void);
static int test_if_case_insensitive(const char *dir_name);
static void create_pid_file();
/****************************************************************************
** Code to end mysqld
--- 499,505 ----
static void clean_up_mutexes(void);
static int test_if_case_insensitive(const char *dir_name);
static void create_pid_file();
+ static uint get_thread_lib(void);
/****************************************************************************
** Code to end mysqld
***************
*** 544,550 ****
DBUG_PRINT("info",("Waiting for select_thread"));
#ifndef DONT_USE_THR_ALARM
! if (pthread_kill(select_thread,THR_CLIENT_ALARM))
break; // allready dead
#endif
set_timespec(abstime, 2);
--- 539,546 ----
DBUG_PRINT("info",("Waiting for select_thread"));
#ifndef DONT_USE_THR_ALARM
! if (pthread_kill(select_thread,
! thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1))
break; // allready dead
#endif
set_timespec(abstime, 2);
***************
*** 844,850 ****
sig,my_thread_id());
}
#ifdef DONT_REMEMBER_SIGNAL
! sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
if (sig == SIGALRM)
--- 840,846 ----
sig,my_thread_id());
}
#ifdef DONT_REMEMBER_SIGNAL
! my_sigset(sig, print_signal_warning); /* int. thread system calls */
#endif
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
if (sig == SIGALRM)
***************
*** 1841,1848 ****
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
! sigset(THR_KILL_SIGNAL,end_thread_signal);
! sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
{
--- 1837,1847 ----
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
! {
! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2,
! end_thread_signal);
! }
! my_sigset(THR_SERVER_ALARM, print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
{
***************
*** 1877,1883 ****
#endif
(void) sigemptyset(&set);
#ifdef THREAD_SPECIFIC_SIGPIPE
! sigset(SIGPIPE,abort_thread);
sigaddset(&set,SIGPIPE);
#else
(void) signal(SIGPIPE,SIG_IGN); // Can't know which thread
--- 1876,1882 ----
#endif
(void) sigemptyset(&set);
#ifdef THREAD_SPECIFIC_SIGPIPE
! my_sigset(SIGPIPE, abort_thread);
sigaddset(&set,SIGPIPE);
#else
(void) signal(SIGPIPE,SIG_IGN); // Can't know which thread
***************
*** 2237,2244 ****
MY_INIT(argv[0]); // init my_sys library & pthreads
tzset(); // Set tzname
start_time=time((time_t*) 0);
-
#ifdef OS2
{
// fix timezone for daylight saving
--- 2236,2243 ----
MY_INIT(argv[0]); // init my_sys library & pthreads
tzset(); // Set tzname
+ thd_lib_detected= get_thread_lib();
start_time=time((time_t*) 0);
#ifdef OS2
{
// fix timezone for daylight saving
***************
*** 5547,5552 ****
(void) my_write(file, (byte*) buff, (uint) (end-buff),MYF(MY_WME));
(void) my_close(file, MYF(0));
}
}
--- 5546,5567 ----
(void) my_write(file, (byte*) buff, (uint) (end-buff),MYF(MY_WME));
(void) my_close(file, MYF(0));
}
+ }
+
+
+ static uint get_thread_lib(void)
+ {
+ char buff[64];
+
+ #ifdef _CS_GNU_LIBPTHREAD_VERSION
+ confstr(_CS_GNU_LIBPTHREAD_VERSION, buff, sizeof(buff));
+
+ if (!strncasecmp(buff, "NPTL", 4))
+ return THD_LIB_NPTL;
+ else if (!strncasecmp(buff, "linuxthreads", 12))
+ return THD_LIB_LT;
+ #endif
+ return THD_LIB_OTHER;
}
This diff is collapsed.
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
class Sql_alloc class Sql_alloc
{ {
public: public:
static void *operator new(size_t size) static void *operator new(size_t size) throw ()
{ {
return (void*) sql_alloc((uint) size); return (void*) sql_alloc((uint) size);
} }
...@@ -31,9 +31,9 @@ class Sql_alloc ...@@ -31,9 +31,9 @@ class Sql_alloc
{ {
return (void*) sql_alloc((uint) size); return (void*) sql_alloc((uint) size);
} }
static void *operator new[](size_t size, MEM_ROOT *mem_root) static void *operator new[](size_t size, MEM_ROOT *mem_root) throw ()
{ return (void*) alloc_root(mem_root, (uint) size); } { return (void*) alloc_root(mem_root, (uint) size); }
static void *operator new(size_t size, MEM_ROOT *mem_root) static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
{ return (void*) alloc_root(mem_root, (uint) size); } { return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); }
static void operator delete(void *ptr, MEM_ROOT *mem_root) static void operator delete(void *ptr, MEM_ROOT *mem_root)
......
...@@ -8793,12 +8793,12 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, ...@@ -8793,12 +8793,12 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
enum enum_field_types type; enum enum_field_types type;
/* /*
DATE/TIME fields have STRING_RESULT result type. To preserve DATE/TIME and GEOMETRY fields have STRING_RESULT result type.
type they needed to be handled separately. To preserve type they needed to be handled separately.
*/ */
if ((type= item->field_type()) == MYSQL_TYPE_DATETIME || if ((type= item->field_type()) == MYSQL_TYPE_DATETIME ||
type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE || type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE ||
type == MYSQL_TYPE_TIMESTAMP) type == MYSQL_TYPE_TIMESTAMP || type == MYSQL_TYPE_GEOMETRY)
new_field= item->tmp_table_field_from_field_type(table); new_field= item->tmp_table_field_from_field_type(table);
/* /*
Make sure that the blob fits into a Field_varstring which has Make sure that the blob fits into a Field_varstring which has
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment