Commit 8e8e4fe0 authored by unknown's avatar unknown

Merge laptop.sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1

into laptop.sanja.is.com.ua:/home/bell/mysql/bk/work-collation-4.1

parents b51b167e 91dc31d3
......@@ -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;
......@@ -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;
......@@ -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;
......@@ -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;
......
......@@ -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));
......
......@@ -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);
......
......@@ -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)))
......
......@@ -4380,6 +4380,7 @@ keyword:
| BOOL_SYM {}
| BOOLEAN_SYM {}
| BYTE_SYM {}
| BTREE_SYM {}
| CACHE_SYM {}
| CHANGED {}
| CHARSET {}
......@@ -4425,6 +4426,7 @@ keyword:
| GRANTS {}
| GLOBAL_SYM {}
| HANDLER_SYM {}
| HASH_SYM {}
| HEAP_SYM {}
| HELP_SYM {}
| HOSTS_SYM {}
......@@ -4507,6 +4509,7 @@ keyword:
| ROWS_SYM {}
| ROW_FORMAT_SYM {}
| ROW_SYM {}
| RTREE_SYM {}
| SAVEPOINT_SYM {}
| SECOND_SYM {}
| SERIAL_SYM {}
......
......@@ -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);
}
......
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