diff options
author | unknown <monty@mashka.mysql.fi> | 2003-01-28 08:38:28 +0200 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2003-01-28 08:38:28 +0200 |
commit | 84f81dc593e8e21cbfb4596aef375d45e3a26ba8 (patch) | |
tree | b916d4acfbe4f32ab06b052fd06c072f858bdce1 /sql/sql_select.cc | |
parent | 49e0eea578eb119cafb2df1ba77b35fcf8391224 (diff) | |
download | mariadb-git-84f81dc593e8e21cbfb4596aef375d45e3a26ba8.tar.gz |
Fixes for Netware
Call pthread_mutex_destroy() on not used mutex.
Changed comments in .h and .c files from // -> /* */
Added detection of mutex on which one didn't call pthread_mutex_destroy()
Fixed bug in create_tmp_field() which causes a memory overrun in queries that uses "ORDER BY constant_expression"
Added optimisation for ORDER BY NULL
BitKeeper/deleted/.del-ChangeLog~dfc92e15bee6fc75:
Delete: sql/ChangeLog
BUILD/compile-pentium-valgrind-max:
Don't use valgrind with safemalloc as this can hide some bugs
Makefile.am:
Added platform dirs
bdb/os/os_handle.c:
Portability fix
client/mysql.cc:
Fixes for Netware.
Fixed duplicate output when using 'tee'
Simple optimisations
client/mysqldump.c:
Portability fix
client/mysqltest.c:
Portability fix
configure.in:
Fixes for Netware
extra/resolveip.c:
Fixes for Netware
include/Makefile.am:
Fixes for Netware
include/config-win.h:
Portability fix
include/my_global.h:
Fixes for Netware
include/my_net.h:
Fixes for Netware
include/my_pthread.h:
Fixes for Netware
Added detection of mutexes that was not destroyed
include/my_sys.h:
Fixes for Netware
Added 'extern' before external functions
include/mysql.h:
Fixes for Netware
innobase/configure.in:
Fixes for Netware
innobase/include/os0thread.h:
Fixes for Netware
innobase/os/os0sync.c:
Fixes for Netware
innobase/os/os0thread.c:
Fixes for Netware
innobase/srv/srv0srv.c:
Fixes for Netware
innobase/srv/srv0start.c:
Fixes for Netware
innobase/sync/sync0sync.c:
Fixes for Netware
isam/test3.c:
Disable test on Netware
libmysql/Makefile.shared:
Added my_sleep
libmysql/get_password.c:
Fixes for Netware
libmysql/libmysql.c:
Fixes for Netware
Made mysql_once_init() global
libmysql/manager.c:
Fixes for Netware
myisam/mi_test3.c:
Disable test for netware
mysql-test/mysql-test-run.sh:
Give warning if output file contains errors
mysql-test/r/count_distinct.result:
More tests
mysql-test/r/group_by.result:
Test of ORDER BY NULL
mysql-test/t/backup.test:
Fixes for Netware
mysql-test/t/count_distinct.test:
More tests
mysql-test/t/func_crypt.test:
Fixes for Netware
mysql-test/t/grant_cache.test:
Fixes for Netware
mysql-test/t/group_by.test:
Tests of ORDER BY NULL
mysql-test/t/rpl000015.test:
Fixes for Netware
mysql-test/t/rpl000017.test:
Fixes for Netware
mysql-test/t/rpl_rotate_logs.test:
Fixes for Netware
mysys/Makefile.am:
Added my_sleep.c and my_netware.c
mysys/charset.c:
Fixes for Netware
mysys/default.c:
Fixes for Netware
mysys/mf_tempfile.c:
Fixes for Netware
mysys/my_clock.c:
Fixes for Netware
mysys/my_copy.c:
Fixes for Netware
mysys/my_getwd.c:
Changed function comment from // -> /* */
mysys/my_init.c:
Fixes for Netware
mysys/my_lock.c:
Fixes for Netware
mysys/my_messnc.c:
Fixes for Netware
mysys/my_os2cond.c:
Removed comment
mysys/my_os2dirsrch.c:
Changed function comment from // -> /* */
Fixed indentation
mysys/my_os2dirsrch.h:
Changed function comment from // -> /* */
Fixed indentation
mysys/my_os2file64.c:
Changed function comment from // -> /* */
Fixed indentation
mysys/my_os2mutex.c:
Changed function comment from // -> /* */
Fixed indentation
mysys/my_os2thread.c:
Changed function comment from // -> /* */
Fixed indentation
mysys/my_os2tls.c:
Changed function comment from // -> /* */
Fixed indentation
mysys/my_pthread.c:
Fixes for Netware
mysys/my_redel.c:
Fixes for Netware
mysys/my_tempnam.c:
Fixes for Netware
mysys/my_thr_init.c:
Remove created mutexes when program ends.
mysys/mysys_priv.h:
Cleanup
mysys/safemalloc.c:
Prefix error messages with "Error:"
mysys/thr_alarm.c:
Destroy internal mutex on end_thr_alarm.
mysys/thr_mutex.c:
Added detection of mutex on which one didn't call pthread_mutex_destroy()
scripts/make_binary_distribution.sh:
Fixes for Netware
sql/des_key_file.cc:
Free mutex at end
sql/ha_innodb.cc:
Free mutex at end
sql/ha_myisam.cc:
Changed warnings from REPAIR Note:
(For mysql-test-run)
sql/hostname.cc:
Fixes for Netware
sql/item.h:
Fixed bug in create_tmp_field() which causes a memory overrun
sql/item_func.cc:
Free used mutexes
sql/item_sum.cc:
Fixed bug in create_tmp_field() which causes a memory overrun
sql/log.cc:
Free used mutexes
sql/my_lock.c:
Fixes for Netware
sql/mysql_priv.h:
Fixes for Netware
sql/mysqld.cc:
Fixes for Netware
Added Have_crypt
Properly free mutexes from MYSQL_LOG by calling cleanup
Free mutex before exit
sql/repl_failsafe.cc:
Fixes for Netware
sql/set_var.cc:
Added have_crypt
sql/share/english/errmsg.txt:
Added version socket and port to stderr log
sql/slave.cc:
Remove global MASTER_INFO variable and use instead an allocated variable.
This allows us to correctly free used mutex.
sql/slave.h:
Move constructors and destuctors to slave.cc
(To make it easier to clear all needed variables)
sql/sql_base.cc:
Safety fix
sql/sql_class.h:
Portability fixes.
Added 'cleanup' to log handling to be able to free mutexes.
sql/sql_insert.cc:
Fixes for Netware
mysys/my_sleep.c:
E
sql/sql_parse.cc:
Fixes for Netware
sql/sql_select.cc:
Added optimisation for ORDER BY NULL
sql/sql_select.h:
Fixed bug in create_tmp_field() which causes a memory overrun
sql/sql_table.cc:
Fixed bug in create_tmp_field() which causes a memory overrun
sql/sql_udf.cc:
Free mutex on end
vio/test-ssl.c:
Simple code cleanup
vio/test-sslclient.c:
Simple code cleanup
vio/test-sslserver.c:
Simple code cleanup
vio/viotest-ssl.c:
Simple code cleanup
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e811c55ed1b..6996bba8798 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -506,7 +506,16 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, error= -1; /* if goto err */ /* Optimize distinct away if possible */ - order=remove_const(&join,order,conds,&simple_order); + { + ORDER *org_order= order; + order=remove_const(&join,order,conds,&simple_order); + /* + If we are using ORDER BY NULL or ORDER BY const_expression, + return result in any order (even if we are using a GROUP BY) + */ + if (!order && org_order) + skip_sort_order= 1; + } if (group || join.tmp_table_param.sum_func_count) { if (! hidden_group_fields) @@ -776,7 +785,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, procedure->update_refs(); if (tmp_table->group) { // Already grouped - if (!order && !no_order) + if (!order && !no_order && !skip_sort_order) order=group; /* order by group */ group=0; } @@ -3529,7 +3538,7 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) */ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, - Item_result_field ***copy_func, Field **from_field, + Item ***copy_func, Field **from_field, bool group, bool modify_item) { switch (type) { @@ -3590,12 +3599,12 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, } return new_field; } - case Item::PROC_ITEM: case Item::FUNC_ITEM: case Item::COND_ITEM: case Item::FIELD_AVG_ITEM: case Item::FIELD_STD_ITEM: /* The following can only happen with 'CREATE TABLE ... SELECT' */ + case Item::PROC_ITEM: case Item::INT_ITEM: case Item::REAL_ITEM: case Item::STRING_ITEM: @@ -3624,10 +3633,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, item->name,table,item->binary); break; } - if (copy_func) - *((*copy_func)++) = (Item_result_field*) item; // Save for copy_funcs + if (copy_func && item->is_result_field()) + *((*copy_func)++) = item; // Save for copy_funcs if (modify_item) - ((Item_result_field*) item)->result_field=new_field; + item->set_result_field(new_field); return new_field; } default: // Dosen't have to be stored @@ -3661,7 +3670,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, Copy_field *copy=0; KEY *keyinfo; KEY_PART_INFO *key_part_info; - Item_result_field **copy_func; + Item **copy_func; MI_COLUMNDEF *recinfo; uint temp_pool_slot=MY_BIT_NONE; @@ -3725,7 +3734,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, my_free((gptr) table,MYF(0)); /* purecov: inspected */ DBUG_RETURN(NULL); /* purecov: inspected */ } - param->funcs=copy_func; + param->items_to_copy= copy_func; strmov(tmpname,path); /* make table according to fields */ @@ -5257,7 +5266,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), if (!end_of_records) { copy_fields(&join->tmp_table_param); - copy_funcs(join->tmp_table_param.funcs); + copy_funcs(join->tmp_table_param.items_to_copy); #ifdef TO_BE_DELETED if (!table->uniques) // If not unique handling @@ -5357,7 +5366,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), memcpy(table->record[0]+key_part->offset, group->buff, key_part->length); init_tmptable_sum_functions(join->sum_funcs); - copy_funcs(join->tmp_table_param.funcs); + copy_funcs(join->tmp_table_param.items_to_copy); if ((error=table->file->write_row(table->record[0]))) { if (create_myisam_from_heap(table, &join->tmp_table_param, error, 0)) @@ -5390,7 +5399,7 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), init_tmptable_sum_functions(join->sum_funcs); copy_fields(&join->tmp_table_param); // Groups are copied twice. - copy_funcs(join->tmp_table_param.funcs); + copy_funcs(join->tmp_table_param.items_to_copy); if (!(error=table->file->write_row(table->record[0]))) join->send_records++; // New group @@ -5475,7 +5484,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), if (idx < (int) join->send_group_parts) { copy_fields(&join->tmp_table_param); - copy_funcs(join->tmp_table_param.funcs); + copy_funcs(join->tmp_table_param.items_to_copy); init_sum_functions(join->sum_funcs); if (join->procedure) join->procedure->add(); @@ -7144,7 +7153,7 @@ copy_sum_funcs(Item_sum **func_ptr) { Item_sum *func; for (; (func = *func_ptr) ; func_ptr++) - (void) func->save_in_field(func->result_field, 1); + (void) func->save_in_result_field(1); return; } @@ -7171,12 +7180,11 @@ update_sum_func(Item_sum **func_ptr) /* Copy result of functions to record in tmp_table */ void -copy_funcs(Item_result_field **func_ptr) +copy_funcs(Item **func_ptr) { - Item_result_field *func; + Item *func; for (; (func = *func_ptr) ; func_ptr++) - (void) func->save_in_field(func->result_field, 1); - return; + func->save_in_result_field(1); } |