diff options
author | unknown <monty@hundin.mysql.fi> | 2001-11-04 16:14:09 +0200 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-11-04 16:14:09 +0200 |
commit | 0d1ba873aa11ea581ebbda9f450027329f2e1a3b (patch) | |
tree | 689c9d0271e23431f1ab0ac09e1af4d68a58ca76 /sql/sql_select.cc | |
parent | 9f90ff3f12f1fc2bcb70cde74dbd6f27e33e230c (diff) | |
parent | 0176dacd54b7eb62ebc4a81909b189517aee2cb4 (diff) | |
download | mariadb-git-0d1ba873aa11ea581ebbda9f450027329f2e1a3b.tar.gz |
merge with 3.23.44
BitKeeper/etc/ignore:
auto-union
BitKeeper/etc/logging_ok:
auto-union
Docs/manual.texi:
Auto merged
include/my_base.h:
Auto merged
mysql-test/t/func_time.test:
Auto merged
mysql-test/t/join.test:
Auto merged
mysql-test/t/rpl000012.test:
Auto merged
BUILD/FINISH.sh:
Auto merged
BitKeeper/deleted/.del-db_ext.h~a1e210bbd0de0a48:
Auto merged
BitKeeper/deleted/.del-mutex_ext.h~f20f47ddc346598b:
Auto merged
BitKeeper/deleted/.del-violite.c~984c09cffe14a11b:
Auto merged
BitKeeper/deleted/.del-violite.c~d7b85be615595ace:
Auto merged
Build-tools/Do-all-build-steps:
Auto merged
client/client_priv.h:
Auto merged
client/mysqladmin.c:
Auto merged
innobase/include/srv0srv.h:
Auto merged
innobase/include/univ.i:
Auto merged
innobase/log/log0log.c:
Auto merged
innobase/srv/srv0srv.c:
Auto merged
innobase/srv/srv0start.c:
Auto merged
isam/pack_isam.c:
Auto merged
libmysql_r/Makefile.am:
Auto merged
myisam/myisamchk.c:
Auto merged
mysql-test/t/having.test:
Auto merged
mysql-test/t/rpl000015-slave.sh:
Auto merged
mysql-test/t/rpl000016-slave.sh:
Auto merged
mysys/mf_cache.c:
Auto merged
mysys/mf_casecnv.c:
Auto merged
mysys/mf_tempfile.c:
Auto merged
readline/vi_mode.c:
Auto merged
strings/strto.c:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/ha_berkeley.cc:
Auto merged
sql/ha_myisammrg.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item.h:
Auto merged
sql/log_event.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/time.cc:
Auto merged
BUILD/SETUP.sh:
Use -mcpu as default (safe for all x86 cpu's)
client/mysqldump.c:
Merge from 3.23.44
configure.in:
Update version number
extra/resolveip.c:
Portability fix
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f2c25e89bd8..fea3dd7728b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3185,7 +3185,8 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) /* fix to replace 'NULL' dates with '0' (shreeve@uci.edu) */ else if (((field->type() == FIELD_TYPE_DATE) || (field->type() == FIELD_TYPE_DATETIME)) && - (field->flags & NOT_NULL_FLAG)) + (field->flags & NOT_NULL_FLAG) && + !field->table->maybe_null) { COND *new_cond; if ((new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2)))) @@ -4083,14 +4084,17 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) { if (table->group && join->tmp_table_param.sum_func_count) { - DBUG_PRINT("info",("Using end_update")); if (table->keys) { + DBUG_PRINT("info",("Using end_update")); end_select=end_update; table->file->index_init(0); } else + { + DBUG_PRINT("info",("Using end_unique_update")); end_select=end_unique_update; + } } else if (join->sort_and_group) { @@ -4206,8 +4210,6 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) int error; bool found=0; COND *on_expr=join_tab->on_expr, *select_cond=join_tab->select_cond; - int (*next_select)(JOIN *,struct st_join_table *,bool)= - join_tab->next_select; if (!(error=(*join_tab->read_first_record)(join_tab))) { @@ -4215,7 +4217,6 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) bool not_used_in_distinct=join_tab->not_used_in_distinct; ha_rows found_records=join->found_records; READ_RECORD *info= &join_tab->read_record; - join->examined_rows++; do { @@ -4224,6 +4225,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) my_error(ER_SERVER_SHUTDOWN,MYF(0)); /* purecov: inspected */ return -2; /* purecov: inspected */ } + join->examined_rows++; if (!on_expr || on_expr->val_int()) { found=1; @@ -4231,7 +4233,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) break; // Searching after not null columns if (!select_cond || select_cond->val_int()) { - if ((error=(*next_select)(join,join_tab+1,0)) < 0) + if ((error=(*join_tab->next_select)(join,join_tab+1,0)) < 0) return error; if (not_used_in_distinct && found_records != join->found_records) return 0; @@ -4252,7 +4254,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) mark_as_null_row(join_tab->table); // For group by without error if (!select_cond || select_cond->val_int()) { - if ((error=(*next_select)(join,join_tab+1,0)) < 0) + if ((error=(*join_tab->next_select)(join,join_tab+1,0)) < 0) return error; /* purecov: inspected */ } } @@ -5449,6 +5451,41 @@ err: DBUG_RETURN(-1); } +/* +** Add the HAVING criteria to table->select +*/ + +#ifdef NOT_YET +static bool fix_having(JOIN *join, Item **having) +{ + (*having)->update_used_tables(); // Some tables may have been const + JOIN_TAB *table=&join->join_tab[join->const_tables]; + table_map used_tables= join->const_table_map | table->table->map; + + DBUG_EXECUTE("where",print_where(*having,"having");); + Item* sort_table_cond=make_cond_for_table(*having,used_tables,used_tables); + if (sort_table_cond) + { + if (!table->select) + if (!(table->select=new SQL_SELECT)) + return 1; + if (!table->select->cond) + table->select->cond=sort_table_cond; + else // This should never happen + if (!(table->select->cond=new Item_cond_and(table->select->cond, + sort_table_cond))) + return 1; + table->select_cond=table->select->cond; + DBUG_EXECUTE("where",print_where(table->select_cond, + "select and having");); + *having=make_cond_for_table(*having,~ (table_map) 0,~used_tables); + DBUG_EXECUTE("where",print_where(*having,"having after make_cond");); + } + return 0; +} +#endif + + /***************************************************************************** ** Remove duplicates from tmp table ** This should be recoded to add a uniuqe index to the table and remove |