diff options
-rw-r--r-- | mysql-test/r/olap.result | 15 | ||||
-rw-r--r-- | mysql-test/r/subselect.result | 8 | ||||
-rw-r--r-- | mysql-test/t/loaddata.test | 4 | ||||
-rw-r--r-- | mysql-test/t/olap.test | 11 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 11 | ||||
-rw-r--r-- | mysys/my_malloc.c | 34 | ||||
-rw-r--r-- | mysys/my_realloc.c | 33 | ||||
-rw-r--r-- | sql-common/client.c | 2 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 25 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 3 | ||||
-rw-r--r-- | sql/table.cc | 7 |
12 files changed, 102 insertions, 53 deletions
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 0b7a98e3fb3..84e37bf56a9 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -254,3 +254,18 @@ ERROR 42000: This version of MySQL doesn't yet support 'CUBE' select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube union all select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup; ERROR 42000: This version of MySQL doesn't yet support 'CUBE' drop table t1,t2; +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES(100); +CREATE TABLE t2 (i int); +INSERT INTO t2 VALUES (100),(200); +SELECT i, COUNT(*) FROM t1 GROUP BY i WITH ROLLUP; +i COUNT(*) +100 1 +NULL 1 +SELECT t1.i, t2.i, COUNT(*) FROM t1,t2 GROUP BY t1.i,t2.i WITH ROLLUP; +i i COUNT(*) +100 100 1 +100 200 1 +100 NULL 2 +NULL NULL 2 +drop table t1,t2; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 3ce43641ad8..cf02eda9aba 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1344,3 +1344,11 @@ a 2 10 drop table t1,t2; +CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci, +s2 CHAR(5) COLLATE latin1_swedish_ci); +INSERT INTO t1 VALUES ('z','?'); +select * from t1 where s1 > (select max(s2) from t1); +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '>' +select * from t1 where s1 > any (select max(s2) from t1); +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '>' +drop table t1; diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 2f484d30ff7..199da9c4a84 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -15,7 +15,3 @@ truncate table t1; load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); SELECT * from t1; drop table t1; - - - - diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 3b1e3fac7c2..17bf6230f76 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -77,3 +77,14 @@ select product, country_id , year, sum(profit) from t1 group by product, country drop table t1,t2; +# +# Test bug with const tables +# + +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES(100); +CREATE TABLE t2 (i int); +INSERT INTO t2 VALUES (100),(200); +SELECT i, COUNT(*) FROM t1 GROUP BY i WITH ROLLUP; +SELECT t1.i, t2.i, COUNT(*) FROM t1,t2 GROUP BY t1.i,t2.i WITH ROLLUP; +drop table t1,t2; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index e1c9e09ae6d..457b64a5a11 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -901,3 +901,14 @@ insert into t3 values (1),(2),(10),(50); select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30); drop table t1,t2; +# +# collation test +# +CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci, + s2 CHAR(5) COLLATE latin1_swedish_ci); +INSERT INTO t1 VALUES ('z','?'); +-- error 1266 +select * from t1 where s1 > (select max(s2) from t1); +-- error 1266 +select * from t1 where s1 > any (select max(s2) from t1); +drop table t1; diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index b273363aaf1..df9fe1f9bc4 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -24,26 +24,26 @@ /* My memory allocator */ -gptr my_malloc(unsigned int Size, myf MyFlags) +gptr my_malloc(unsigned int size, myf my_flags) { gptr point; DBUG_ENTER("my_malloc"); - DBUG_PRINT("my",("Size: %u MyFlags: %d",Size, MyFlags)); + DBUG_PRINT("my",("size: %u my_flags: %d",size, my_flags)); - if (!Size) - Size=1; /* Safety */ - if ((point = (char*)malloc(Size)) == NULL) + if (!size) + size=1; /* Safety */ + if ((point = (char*)malloc(size)) == NULL) { my_errno=errno; - if (MyFlags & MY_FAE) + if (my_flags & MY_FAE) error_handler_hook=fatal_error_handler_hook; - if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),Size); - if (MyFlags & MY_FAE) + if (my_flags & (MY_FAE+MY_WME)) + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size); + if (my_flags & MY_FAE) exit(1); } - else if (MyFlags & MY_ZEROFILL) - bzero(point,Size); + else if (my_flags & MY_ZEROFILL) + bzero(point,size); DBUG_PRINT("exit",("ptr: %lx",point)); DBUG_RETURN(point); } /* my_malloc */ @@ -64,29 +64,29 @@ void my_no_flags_free(gptr ptr) /* malloc and copy */ -gptr my_memdup(const byte *from, uint length, myf MyFlags) +gptr my_memdup(const byte *from, uint length, myf my_flags) { gptr ptr; - if ((ptr=my_malloc(length,MyFlags)) != 0) + if ((ptr=my_malloc(length,my_flags)) != 0) memcpy((byte*) ptr, (byte*) from,(size_t) length); return(ptr); } -char *my_strdup(const char *from, myf MyFlags) +char *my_strdup(const char *from, myf my_flags) { gptr ptr; uint length=(uint) strlen(from)+1; - if ((ptr=my_malloc(length,MyFlags)) != 0) + if ((ptr=my_malloc(length,my_flags)) != 0) memcpy((byte*) ptr, (byte*) from,(size_t) length); return((my_string) ptr); } -char *my_strdup_with_length(const byte *from, uint length, myf MyFlags) +char *my_strdup_with_length(const byte *from, uint length, myf my_flags) { gptr ptr; - if ((ptr=my_malloc(length+1,MyFlags)) != 0) + if ((ptr=my_malloc(length+1,my_flags)) != 0) { memcpy((byte*) ptr, (byte*) from,(size_t) length); ((char*) ptr)[length]=0; diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c index 49d96c2eb4f..5190fa75dce 100644 --- a/mysys/my_realloc.c +++ b/mysys/my_realloc.c @@ -23,40 +23,41 @@ /* My memory re allocator */ -gptr my_realloc(gptr oldpoint, uint Size, myf MyFlags) +gptr my_realloc(gptr oldpoint, uint size, myf my_flags) { gptr point; DBUG_ENTER("my_realloc"); - DBUG_PRINT("my",("ptr: %lx Size: %u MyFlags: %d",oldpoint, Size, MyFlags)); + DBUG_PRINT("my",("ptr: %lx size: %u my_flags: %d",oldpoint, size, + my_flags)); - if (!oldpoint && (MyFlags & MY_ALLOW_ZERO_PTR)) - DBUG_RETURN(my_malloc(Size,MyFlags)); + if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR)) + DBUG_RETURN(my_malloc(size,my_flags)); #ifdef USE_HALLOC - if (!(point = malloc(Size))) + if (!(point = malloc(size))) { - if (MyFlags & MY_FREE_ON_ERROR) - my_free(oldpoint,MyFlags); - if (MyFlags & MY_HOLD_ON_ERROR) + if (my_flags & MY_FREE_ON_ERROR) + my_free(oldpoint,my_flags); + if (my_flags & MY_HOLD_ON_ERROR) DBUG_RETURN(oldpoint); my_errno=errno; - if (MyFlags & MY_FAE+MY_WME) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),Size); + if (my_flags & MY_FAE+MY_WME) + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size); } else { - memcpy(point,oldpoint,Size); + memcpy(point,oldpoint,size); free(oldpoint); } #else - if ((point = (char*)realloc(oldpoint,Size)) == NULL) + if ((point = (char*)realloc(oldpoint,size)) == NULL) { - if (MyFlags & MY_FREE_ON_ERROR) + if (my_flags & MY_FREE_ON_ERROR) my_free(oldpoint,MyFLAGS); - if (MyFlags & MY_HOLD_ON_ERROR) + if (my_flags & MY_HOLD_ON_ERROR) DBUG_RETURN(oldpoint); my_errno=errno; - if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), Size); + if (my_flags & (MY_FAE+MY_WME)) + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size); } #endif DBUG_PRINT("exit",("ptr: %lx",point)); diff --git a/sql-common/client.c b/sql-common/client.c index 222f0bf0288..25b18c27d8a 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -587,7 +587,7 @@ net_safe_read(MYSQL *mysql) DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", vio_description(net->vio),len)); #ifdef MYSQL_SERVER - if (socket_errno == SOCKET_EINTR) + if (vio_errno(net->vio) == SOCKET_EINTR) return (packet_error); #endif /*MYSQL_SERVER*/ end_server(mysql); diff --git a/sql/item.h b/sql/item.h index 296ad18b1f1..c97b66c8c53 100644 --- a/sql/item.h +++ b/sql/item.h @@ -862,6 +862,7 @@ public: { value= item->val_int_result(); null_value= item->null_value; + collation.set(item->collation); } double val() { return (double) value; } longlong val_int() { return value; } @@ -879,6 +880,7 @@ public: { value= item->val_result(); null_value= item->null_value; + collation.set(item->collation); } double val() { return value; } longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5)); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 15d6b3954ff..412e891bad1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -117,10 +117,8 @@ static Item* part_of_refkey(TABLE *form,Field *field); static uint find_shortest_key(TABLE *table, key_map usable_keys); static bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order, ha_rows select_limit, bool no_changes); -static int create_sort_index(THD *thd, JOIN_TAB *tab,ORDER *order, +static int create_sort_index(THD *thd, JOIN *join, ORDER *order, ha_rows filesort_limit, ha_rows select_limit); -static int create_sort_index(THD *thd, JOIN_TAB *tab,ORDER *order, - ha_rows select_limit); static int remove_duplicates(JOIN *join,TABLE *entry,List<Item> &fields, Item *having); static int remove_dup_with_compare(THD *thd, TABLE *entry, Field **field, @@ -916,7 +914,7 @@ JOIN::optimize() { DBUG_PRINT("info",("Sorting for group")); thd->proc_info="Sorting for group"; - if (create_sort_index(thd, &join_tab[const_tables], group_list, + if (create_sort_index(thd, this, group_list, HA_POS_ERROR, HA_POS_ERROR) || alloc_group_fields(this, group_list) || make_sum_func_list(all_fields, fields_list, 1)) @@ -931,7 +929,7 @@ JOIN::optimize() { DBUG_PRINT("info",("Sorting for order")); thd->proc_info="Sorting for order"; - if (create_sort_index(thd, &join_tab[const_tables], order, + if (create_sort_index(thd, this, order, HA_POS_ERROR, HA_POS_ERROR)) DBUG_RETURN(1); order=0; @@ -1235,7 +1233,7 @@ JOIN::exec() if (curr_join->group_list) { thd->proc_info= "Creating sort index"; - if (create_sort_index(thd, curr_join->join_tab, curr_join->group_list, + if (create_sort_index(thd, curr_join, curr_join->group_list, HA_POS_ERROR, HA_POS_ERROR) || make_group_fields(this, curr_join)) { @@ -1416,7 +1414,7 @@ JOIN::exec() } } } - if (create_sort_index(thd, &curr_join->join_tab[curr_join->const_tables], + if (create_sort_index(thd, curr_join, curr_join->group_list ? curr_join->group_list : curr_join->order, curr_join->select_limit, unit->select_limit_cnt)) @@ -6770,16 +6768,23 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ static int -create_sort_index(THD *thd, JOIN_TAB *tab, ORDER *order, +create_sort_index(THD *thd, JOIN *join, ORDER *order, ha_rows filesort_limit, ha_rows select_limit) { SORT_FIELD *sortorder; uint length; ha_rows examined_rows; - TABLE *table=tab->table; - SQL_SELECT *select=tab->select; + TABLE *table; + SQL_SELECT *select; + JOIN_TAB *tab; DBUG_ENTER("create_sort_index"); + if (join->tables == join->const_tables) + DBUG_RETURN(0); // One row, no need to sort + tab= join->join_tab + join->const_tables; + table= tab->table; + select= tab->select; + if (test_if_skip_sort_order(tab,order,select_limit,0)) DBUG_RETURN(0); if (!(sortorder=make_unireg_sortorder(order,&length))) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3ecd7c2f0a6..24ffd669351 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4420,6 +4420,7 @@ keyword: | BOOL_SYM {} | BOOLEAN_SYM {} | BYTE_SYM {} + | BTREE_SYM {} | CACHE_SYM {} | CHANGED {} | CHARSET {} @@ -4465,6 +4466,7 @@ keyword: | GRANTS {} | GLOBAL_SYM {} | HANDLER_SYM {} + | HASH_SYM {} | HEAP_SYM {} | HELP_SYM {} | HOSTS_SYM {} @@ -4547,6 +4549,7 @@ keyword: | ROWS_SYM {} | ROW_FORMAT_SYM {} | ROW_SYM {} + | RTREE_SYM {} | SAVEPOINT_SYM {} | SECOND_SYM {} | SERIAL_SYM {} diff --git a/sql/table.cc b/sql/table.cc index 9d12de1f6c7..a980e086d60 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1207,17 +1207,14 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res) char *get_field(MEM_ROOT *mem, Field *field) { - char buff[MAX_FIELD_WIDTH], *to; + char buff[MAX_FIELD_WIDTH]; String str(buff,sizeof(buff),&my_charset_bin); uint length; field->val_str(&str,&str); if (!(length= str.length())) return NullS; - to= (char*) alloc_root(mem,length+1); - memcpy(to, str.ptr(), (uint) length); - to[length]=0; - return to; + return strmake_root(mem, str.ptr(), length); } |