mariadb/sql/item_subselect.cc

6025 lines
171 KiB
C++
Raw Normal View History

2012-04-05 10:49:38 +02:00
/* Copyright (c) 2002, 2011, Oracle and/or its affiliates.
simple subselects ported to new select_lex structures include/mysqld_error.h: simple subselects libmysqld/Makefile.am: simple subselects sql/Makefile.am: simple subselects sql/item.h: simple subselects sql/item_strfunc.h: simple subselects sql/share/czech/errmsg.txt: simple subselects sql/share/danish/errmsg.txt: simple subselects sql/share/dutch/errmsg.txt: simple subselects sql/share/english/errmsg.txt: simple subselects sql/share/estonian/errmsg.txt: simple subselects sql/share/french/errmsg.txt: simple subselects sql/share/german/errmsg.txt: simple subselects sql/share/greek/errmsg.txt: simple subselects sql/share/hungarian/errmsg.txt: simple subselects sql/share/italian/errmsg.txt: simple subselects sql/share/japanese/errmsg.txt: simple subselects sql/share/korean/errmsg.txt: simple subselects sql/share/norwegian-ny/errmsg.txt: simple subselects sql/share/norwegian/errmsg.txt: simple subselects sql/share/polish/errmsg.txt: simple subselects sql/share/portuguese/errmsg.txt: simple subselects sql/share/romanian/errmsg.txt: simple subselects sql/share/russian/errmsg.txt: simple subselects sql/share/slovak/errmsg.txt: simple subselects sql/share/spanish/errmsg.txt: simple subselects sql/share/swedish/errmsg.txt: simple subselects sql/share/ukrainian/errmsg.txt: simple subselects sql/sql_class.cc: simple subselects sql/sql_class.h: simple subselects sql/sql_lex.cc: simple subselects sql/sql_select.cc: simple subselects sql/sql_select.h: simple subselects sql/sql_union.cc: simple subselects sql/sql_yacc.yy: simple subselects
2002-05-12 22:46:42 +02:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Many files: Changed header to GPL version 2 only BUILD/Makefile.am: Changed header to GPL version 2 only Docs/Makefile.am: Changed header to GPL version 2 only Makefile.am: Changed header to GPL version 2 only SSL/Makefile.am: Changed header to GPL version 2 only bdb/Makefile.in: Changed header to GPL version 2 only client/Makefile.am: Changed header to GPL version 2 only client/client_priv.h: Changed header to GPL version 2 only client/completion_hash.cc: Changed header to GPL version 2 only client/completion_hash.h: Changed header to GPL version 2 only client/get_password.c: Changed header to GPL version 2 only client/my_readline.h: Changed header to GPL version 2 only client/mysql.cc: Changed header to GPL version 2 only client/mysql_upgrade.c: Changed header to GPL version 2 only client/mysqladmin.cc: Changed header to GPL version 2 only client/mysqlbinlog.cc: Changed header to GPL version 2 only client/mysqlcheck.c: Changed header to GPL version 2 only client/mysqldump.c: Changed header to GPL version 2 only client/mysqlimport.c: Changed header to GPL version 2 only client/mysqlmanager-pwgen.c: Changed header to GPL version 2 only client/mysqlmanagerc.c: Changed header to GPL version 2 only client/mysqlshow.c: Changed header to GPL version 2 only client/mysqltest.c: Changed header to GPL version 2 only client/readline.cc: Changed header to GPL version 2 only client/sql_string.cc: Changed header to GPL version 2 only client/sql_string.h: Changed header to GPL version 2 only cmd-line-utils/Makefile.am: Changed header to GPL version 2 only dbug/Makefile.am: Changed header to GPL version 2 only extra/Makefile.am: Changed header to GPL version 2 only extra/charset2html.c: Changed header to GPL version 2 only extra/comp_err.c: Changed header to GPL version 2 only extra/innochecksum.c: Changed header to GPL version 2 only extra/my_print_defaults.c: Changed header to GPL version 2 only extra/mysql_waitpid.c: Changed header to GPL version 2 only extra/perror.c: Changed header to GPL version 2 only extra/replace.c: Changed header to GPL version 2 only extra/resolve_stack_dump.c: Changed header to GPL version 2 only extra/resolveip.c: Changed header to GPL version 2 only heap/Makefile.am: Changed header to GPL version 2 only heap/_check.c: Changed header to GPL version 2 only heap/_rectest.c: Changed header to GPL version 2 only heap/heapdef.h: Changed header to GPL version 2 only heap/hp_block.c: Changed header to GPL version 2 only heap/hp_clear.c: Changed header to GPL version 2 only heap/hp_close.c: Changed header to GPL version 2 only heap/hp_create.c: Changed header to GPL version 2 only heap/hp_delete.c: Changed header to GPL version 2 only heap/hp_extra.c: Changed header to GPL version 2 only heap/hp_hash.c: Changed header to GPL version 2 only heap/hp_info.c: Changed header to GPL version 2 only heap/hp_open.c: Changed header to GPL version 2 only heap/hp_panic.c: Changed header to GPL version 2 only heap/hp_rename.c: Changed header to GPL version 2 only heap/hp_rfirst.c: Changed header to GPL version 2 only heap/hp_rkey.c: Changed header to GPL version 2 only heap/hp_rlast.c: Changed header to GPL version 2 only heap/hp_rnext.c: Changed header to GPL version 2 only heap/hp_rprev.c: Changed header to GPL version 2 only heap/hp_rrnd.c: Changed header to GPL version 2 only heap/hp_rsame.c: Changed header to GPL version 2 only heap/hp_scan.c: Changed header to GPL version 2 only heap/hp_static.c: Changed header to GPL version 2 only heap/hp_test1.c: Changed header to GPL version 2 only heap/hp_test2.c: Changed header to GPL version 2 only heap/hp_update.c: Changed header to GPL version 2 only heap/hp_write.c: Changed header to GPL version 2 only include/Makefile.am: Changed header to GPL version 2 only include/base64.h: Changed header to GPL version 2 only include/config-netware.h: Changed header to GPL version 2 only include/config-os2.h: Changed header to GPL version 2 only include/config-win.h: Changed header to GPL version 2 only include/decimal.h: Changed header to GPL version 2 only include/errmsg.h: Changed header to GPL version 2 only include/ft_global.h: Changed header to GPL version 2 only include/hash.h: Changed header to GPL version 2 only include/heap.h: Changed header to GPL version 2 only include/keycache.h: Changed header to GPL version 2 only include/m_ctype.h: Changed header to GPL version 2 only include/m_string.h: Changed header to GPL version 2 only include/md5.h: Changed header to GPL version 2 only include/my_aes.h: Changed header to GPL version 2 only include/my_alarm.h: Changed header to GPL version 2 only include/my_alloc.h: Changed header to GPL version 2 only include/my_base.h: Changed header to GPL version 2 only include/my_bitmap.h: Changed header to GPL version 2 only include/my_dbug.h: Changed header to GPL version 2 only include/my_dir.h: Changed header to GPL version 2 only include/my_getopt.h: Changed header to GPL version 2 only include/my_global.h: Changed header to GPL version 2 only include/my_handler.h: Changed header to GPL version 2 only include/my_libwrap.h: Changed header to GPL version 2 only include/my_list.h: Changed header to GPL version 2 only include/my_net.h: Changed header to GPL version 2 only include/my_no_pthread.h: Changed header to GPL version 2 only include/my_nosys.h: Changed header to GPL version 2 only include/my_pthread.h: Changed header to GPL version 2 only include/my_sys.h: Changed header to GPL version 2 only include/my_time.h: Changed header to GPL version 2 only include/my_tree.h: Changed header to GPL version 2 only include/my_user.h: Changed header to GPL version 2 only include/my_xml.h: Changed header to GPL version 2 only include/myisam.h: Changed header to GPL version 2 only include/myisammrg.h: Changed header to GPL version 2 only include/myisampack.h: Changed header to GPL version 2 only include/mysql.h: Changed header to GPL version 2 only include/mysql_com.h: Changed header to GPL version 2 only include/mysql_embed.h: Changed header to GPL version 2 only include/mysql_time.h: Changed header to GPL version 2 only include/mysys_err.h: Changed header to GPL version 2 only include/queues.h: Changed header to GPL version 2 only include/raid.h: Changed header to GPL version 2 only include/rijndael.h: Changed header to GPL version 2 only include/sha1.h: Changed header to GPL version 2 only include/sql_common.h: Changed header to GPL version 2 only include/sslopt-case.h: Changed header to GPL version 2 only include/sslopt-longopts.h: Changed header to GPL version 2 only include/sslopt-vars.h: Changed header to GPL version 2 only include/t_ctype.h: Changed header to GPL version 2 only include/thr_alarm.h: Changed header to GPL version 2 only include/thr_lock.h: Changed header to GPL version 2 only include/typelib.h: Changed header to GPL version 2 only include/violite.h: Changed header to GPL version 2 only innobase/Makefile.am: Changed header to GPL version 2 only innobase/btr/Makefile.am: Changed header to GPL version 2 only innobase/buf/Makefile.am: Changed header to GPL version 2 only innobase/data/Makefile.am: Changed header to GPL version 2 only innobase/dict/Makefile.am: Changed header to GPL version 2 only innobase/dyn/Makefile.am: Changed header to GPL version 2 only innobase/eval/Makefile.am: Changed header to GPL version 2 only innobase/fil/Makefile.am: Changed header to GPL version 2 only innobase/fsp/Makefile.am: Changed header to GPL version 2 only innobase/fut/Makefile.am: Changed header to GPL version 2 only innobase/ha/Makefile.am: Changed header to GPL version 2 only innobase/ibuf/Makefile.am: Changed header to GPL version 2 only innobase/include/Makefile.am: Changed header to GPL version 2 only innobase/lock/Makefile.am: Changed header to GPL version 2 only innobase/log/Makefile.am: Changed header to GPL version 2 only innobase/mach/Makefile.am: Changed header to GPL version 2 only innobase/mem/Makefile.am: Changed header to GPL version 2 only innobase/mtr/Makefile.am: Changed header to GPL version 2 only innobase/os/Makefile.am: Changed header to GPL version 2 only innobase/page/Makefile.am: Changed header to GPL version 2 only innobase/pars/Makefile.am: Changed header to GPL version 2 only innobase/que/Makefile.am: Changed header to GPL version 2 only innobase/read/Makefile.am: Changed header to GPL version 2 only innobase/rem/Makefile.am: Changed header to GPL version 2 only innobase/row/Makefile.am: Changed header to GPL version 2 only innobase/srv/Makefile.am: Changed header to GPL version 2 only innobase/sync/Makefile.am: Changed header to GPL version 2 only innobase/thr/Makefile.am: Changed header to GPL version 2 only innobase/trx/Makefile.am: Changed header to GPL version 2 only innobase/usr/Makefile.am: Changed header to GPL version 2 only innobase/ut/Makefile.am: Changed header to GPL version 2 only libmysql/client_settings.h: Changed header to GPL version 2 only libmysqld/Makefile.am: Changed header to GPL version 2 only libmysqld/emb_qcache.cc: Changed header to GPL version 2 only libmysqld/emb_qcache.h: Changed header to GPL version 2 only libmysqld/embedded_priv.h: Changed header to GPL version 2 only libmysqld/examples/Makefile.am: Changed header to GPL version 2 only libmysqld/libmysqld.c: Changed header to GPL version 2 only man/Makefile.am: Changed header to GPL version 2 only myisam/Makefile.am: Changed header to GPL version 2 only myisam/ft_boolean_search.c: Changed header to GPL version 2 only myisam/ft_eval.c: Changed header to GPL version 2 only myisam/ft_eval.h: Changed header to GPL version 2 only myisam/ft_nlq_search.c: Changed header to GPL version 2 only myisam/ft_parser.c: Changed header to GPL version 2 only myisam/ft_static.c: Changed header to GPL version 2 only myisam/ft_stem.c: Changed header to GPL version 2 only myisam/ft_stopwords.c: Changed header to GPL version 2 only myisam/ft_test1.c: Changed header to GPL version 2 only myisam/ft_test1.h: Changed header to GPL version 2 only myisam/ft_update.c: Changed header to GPL version 2 only myisam/ftdefs.h: Changed header to GPL version 2 only myisam/fulltext.h: Changed header to GPL version 2 only myisam/mi_cache.c: Changed header to GPL version 2 only myisam/mi_changed.c: Changed header to GPL version 2 only myisam/mi_check.c: Changed header to GPL version 2 only myisam/mi_checksum.c: Changed header to GPL version 2 only myisam/mi_close.c: Changed header to GPL version 2 only myisam/mi_create.c: Changed header to GPL version 2 only myisam/mi_dbug.c: Changed header to GPL version 2 only myisam/mi_delete.c: Changed header to GPL version 2 only myisam/mi_delete_all.c: Changed header to GPL version 2 only myisam/mi_delete_table.c: Changed header to GPL version 2 only myisam/mi_dynrec.c: Changed header to GPL version 2 only myisam/mi_extra.c: Changed header to GPL version 2 only myisam/mi_info.c: Changed header to GPL version 2 only myisam/mi_key.c: Changed header to GPL version 2 only myisam/mi_keycache.c: Changed header to GPL version 2 only myisam/mi_locking.c: Changed header to GPL version 2 only myisam/mi_log.c: Changed header to GPL version 2 only myisam/mi_open.c: Changed header to GPL version 2 only myisam/mi_packrec.c: Changed header to GPL version 2 only myisam/mi_page.c: Changed header to GPL version 2 only myisam/mi_panic.c: Changed header to GPL version 2 only myisam/mi_preload.c: Changed header to GPL version 2 only myisam/mi_range.c: Changed header to GPL version 2 only myisam/mi_rename.c: Changed header to GPL version 2 only myisam/mi_rfirst.c: Changed header to GPL version 2 only myisam/mi_rkey.c: Changed header to GPL version 2 only myisam/mi_rlast.c: Changed header to GPL version 2 only myisam/mi_rnext.c: Changed header to GPL version 2 only myisam/mi_rnext_same.c: Changed header to GPL version 2 only myisam/mi_rprev.c: Changed header to GPL version 2 only myisam/mi_rrnd.c: Changed header to GPL version 2 only myisam/mi_rsame.c: Changed header to GPL version 2 only myisam/mi_rsamepos.c: Changed header to GPL version 2 only myisam/mi_scan.c: Changed header to GPL version 2 only myisam/mi_search.c: Changed header to GPL version 2 only myisam/mi_static.c: Changed header to GPL version 2 only myisam/mi_statrec.c: Changed header to GPL version 2 only myisam/mi_test1.c: Changed header to GPL version 2 only myisam/mi_test2.c: Changed header to GPL version 2 only myisam/mi_test3.c: Changed header to GPL version 2 only myisam/mi_unique.c: Changed header to GPL version 2 only myisam/mi_update.c: Changed header to GPL version 2 only myisam/mi_write.c: Changed header to GPL version 2 only myisam/myisam_ftdump.c: Changed header to GPL version 2 only myisam/myisamchk.c: Changed header to GPL version 2 only myisam/myisamdef.h: Changed header to GPL version 2 only myisam/myisamlog.c: Changed header to GPL version 2 only myisam/myisampack.c: Changed header to GPL version 2 only myisam/rt_index.c: Changed header to GPL version 2 only myisam/rt_index.h: Changed header to GPL version 2 only myisam/rt_key.c: Changed header to GPL version 2 only myisam/rt_key.h: Changed header to GPL version 2 only myisam/rt_mbr.c: Changed header to GPL version 2 only myisam/rt_mbr.h: Changed header to GPL version 2 only myisam/rt_split.c: Changed header to GPL version 2 only myisam/rt_test.c: Changed header to GPL version 2 only myisam/sort.c: Changed header to GPL version 2 only myisam/sp_defs.h: Changed header to GPL version 2 only myisam/sp_key.c: Changed header to GPL version 2 only myisam/sp_test.c: Changed header to GPL version 2 only myisammrg/Makefile.am: Changed header to GPL version 2 only myisammrg/myrg_close.c: Changed header to GPL version 2 only myisammrg/myrg_create.c: Changed header to GPL version 2 only myisammrg/myrg_def.h: Changed header to GPL version 2 only myisammrg/myrg_delete.c: Changed header to GPL version 2 only myisammrg/myrg_extra.c: Changed header to GPL version 2 only myisammrg/myrg_info.c: Changed header to GPL version 2 only myisammrg/myrg_locking.c: Changed header to GPL version 2 only myisammrg/myrg_open.c: Changed header to GPL version 2 only myisammrg/myrg_panic.c: Changed header to GPL version 2 only myisammrg/myrg_queue.c: Changed header to GPL version 2 only myisammrg/myrg_range.c: Changed header to GPL version 2 only myisammrg/myrg_rfirst.c: Changed header to GPL version 2 only myisammrg/myrg_rkey.c: Changed header to GPL version 2 only myisammrg/myrg_rlast.c: Changed header to GPL version 2 only myisammrg/myrg_rnext.c: Changed header to GPL version 2 only myisammrg/myrg_rnext_same.c: Changed header to GPL version 2 only myisammrg/myrg_rprev.c: Changed header to GPL version 2 only myisammrg/myrg_rrnd.c: Changed header to GPL version 2 only myisammrg/myrg_rsame.c: Changed header to GPL version 2 only myisammrg/myrg_static.c: Changed header to GPL version 2 only myisammrg/myrg_update.c: Changed header to GPL version 2 only myisammrg/myrg_write.c: Changed header to GPL version 2 only mysql-test/Makefile.am: Changed header to GPL version 2 only mysys/Makefile.am: Changed header to GPL version 2 only mysys/array.c: Changed header to GPL version 2 only mysys/base64.c: Changed header to GPL version 2 only mysys/charset-def.c: Changed header to GPL version 2 only mysys/charset.c: Changed header to GPL version 2 only mysys/checksum.c: Changed header to GPL version 2 only mysys/default.c: Changed header to GPL version 2 only mysys/default_modify.c: Changed header to GPL version 2 only mysys/errors.c: Changed header to GPL version 2 only mysys/hash.c: Changed header to GPL version 2 only mysys/list.c: Changed header to GPL version 2 only mysys/make-conf.c: Changed header to GPL version 2 only mysys/md5.c: Changed header to GPL version 2 only mysys/mf_brkhant.c: Changed header to GPL version 2 only mysys/mf_cache.c: Changed header to GPL version 2 only mysys/mf_dirname.c: Changed header to GPL version 2 only mysys/mf_fn_ext.c: Changed header to GPL version 2 only mysys/mf_format.c: Changed header to GPL version 2 only mysys/mf_getdate.c: Changed header to GPL version 2 only mysys/mf_iocache.c: Changed header to GPL version 2 only mysys/mf_iocache2.c: Changed header to GPL version 2 only mysys/mf_keycache.c: Changed header to GPL version 2 only mysys/mf_keycaches.c: Changed header to GPL version 2 only mysys/mf_loadpath.c: Changed header to GPL version 2 only mysys/mf_pack.c: Changed header to GPL version 2 only mysys/mf_path.c: Changed header to GPL version 2 only mysys/mf_qsort.c: Changed header to GPL version 2 only mysys/mf_qsort2.c: Changed header to GPL version 2 only mysys/mf_radix.c: Changed header to GPL version 2 only mysys/mf_same.c: Changed header to GPL version 2 only mysys/mf_sort.c: Changed header to GPL version 2 only mysys/mf_soundex.c: Changed header to GPL version 2 only mysys/mf_strip.c: Changed header to GPL version 2 only mysys/mf_tempdir.c: Changed header to GPL version 2 only mysys/mf_tempfile.c: Changed header to GPL version 2 only mysys/mf_unixpath.c: Changed header to GPL version 2 only mysys/mf_util.c: Changed header to GPL version 2 only mysys/mf_wcomp.c: Changed header to GPL version 2 only mysys/mf_wfile.c: Changed header to GPL version 2 only mysys/mulalloc.c: Changed header to GPL version 2 only mysys/my_access.c: Changed header to GPL version 2 only mysys/my_aes.c: Changed header to GPL version 2 only mysys/my_alarm.c: Changed header to GPL version 2 only mysys/my_alloc.c: Changed header to GPL version 2 only mysys/my_append.c: Changed header to GPL version 2 only mysys/my_bit.c: Changed header to GPL version 2 only mysys/my_bitmap.c: Changed header to GPL version 2 only mysys/my_chsize.c: Changed header to GPL version 2 only mysys/my_clock.c: Changed header to GPL version 2 only mysys/my_compress.c: Changed header to GPL version 2 only mysys/my_conio.c: Changed header to GPL version 2 only mysys/my_copy.c: Changed header to GPL version 2 only mysys/my_crc32.c: Changed header to GPL version 2 only mysys/my_create.c: Changed header to GPL version 2 only mysys/my_delete.c: Changed header to GPL version 2 only mysys/my_div.c: Changed header to GPL version 2 only mysys/my_dup.c: Changed header to GPL version 2 only mysys/my_error.c: Changed header to GPL version 2 only mysys/my_file.c: Changed header to GPL version 2 only mysys/my_fopen.c: Changed header to GPL version 2 only mysys/my_fstream.c: Changed header to GPL version 2 only mysys/my_gethostbyname.c: Changed header to GPL version 2 only mysys/my_gethwaddr.c: Changed header to GPL version 2 only mysys/my_getopt.c: Changed header to GPL version 2 only mysys/my_getpagesize.c: Changed header to GPL version 2 only mysys/my_getsystime.c: Changed header to GPL version 2 only mysys/my_getwd.c: Changed header to GPL version 2 only mysys/my_handler.c: Changed header to GPL version 2 only mysys/my_init.c: Changed header to GPL version 2 only mysys/my_largepage.c: Changed header to GPL version 2 only mysys/my_lib.c: Changed header to GPL version 2 only mysys/my_libwrap.c: Changed header to GPL version 2 only mysys/my_lock.c: Changed header to GPL version 2 only mysys/my_lockmem.c: Changed header to GPL version 2 only mysys/my_lread.c: Changed header to GPL version 2 only mysys/my_lwrite.c: Changed header to GPL version 2 only mysys/my_malloc.c: Changed header to GPL version 2 only mysys/my_messnc.c: Changed header to GPL version 2 only mysys/my_mkdir.c: Changed header to GPL version 2 only mysys/my_mmap.c: Changed header to GPL version 2 only mysys/my_net.c: Changed header to GPL version 2 only mysys/my_netware.c: Changed header to GPL version 2 only mysys/my_new.cc: Changed header to GPL version 2 only mysys/my_once.c: Changed header to GPL version 2 only mysys/my_open.c: Changed header to GPL version 2 only mysys/my_os2cond.c: Changed header to GPL version 2 only mysys/my_os2dirsrch.c: Changed header to GPL version 2 only mysys/my_os2dirsrch.h: Changed header to GPL version 2 only mysys/my_os2dlfcn.c: Changed header to GPL version 2 only mysys/my_os2dlfcn.h0: Changed header to GPL version 2 only mysys/my_os2file64.c: Changed header to GPL version 2 only mysys/my_os2thread.c: Changed header to GPL version 2 only mysys/my_os2tls.c: Changed header to GPL version 2 only mysys/my_port.c: Changed header to GPL version 2 only mysys/my_pread.c: Changed header to GPL version 2 only mysys/my_pthread.c: Changed header to GPL version 2 only mysys/my_quick.c: Changed header to GPL version 2 only mysys/my_read.c: Changed header to GPL version 2 only mysys/my_realloc.c: Changed header to GPL version 2 only mysys/my_redel.c: Changed header to GPL version 2 only mysys/my_rename.c: Changed header to GPL version 2 only mysys/my_seek.c: Changed header to GPL version 2 only mysys/my_semaphore.c: Changed header to GPL version 2 only mysys/my_sleep.c: Changed header to GPL version 2 only mysys/my_static.c: Changed header to GPL version 2 only mysys/my_static.h: Changed header to GPL version 2 only mysys/my_symlink.c: Changed header to GPL version 2 only mysys/my_symlink2.c: Changed header to GPL version 2 only mysys/my_sync.c: Changed header to GPL version 2 only mysys/my_thr_init.c: Changed header to GPL version 2 only mysys/my_wincond.c: Changed header to GPL version 2 only mysys/my_windac.c: Changed header to GPL version 2 only mysys/my_winthread.c: Changed header to GPL version 2 only mysys/my_write.c: Changed header to GPL version 2 only mysys/mysys_priv.h: Changed header to GPL version 2 only mysys/ptr_cmp.c: Changed header to GPL version 2 only mysys/queues.c: Changed header to GPL version 2 only mysys/raid.cc: Changed header to GPL version 2 only mysys/raid2.c: Changed header to GPL version 2 only mysys/rijndael.c: Changed header to GPL version 2 only mysys/safemalloc.c: Changed header to GPL version 2 only mysys/sha1.c: Changed header to GPL version 2 only mysys/string.c: Changed header to GPL version 2 only mysys/test_charset.c: Changed header to GPL version 2 only mysys/test_dir.c: Changed header to GPL version 2 only mysys/test_fn.c: Changed header to GPL version 2 only mysys/test_xml.c: Changed header to GPL version 2 only mysys/testhash.c: Changed header to GPL version 2 only mysys/thr_alarm.c: Changed header to GPL version 2 only mysys/thr_lock.c: Changed header to GPL version 2 only mysys/thr_mutex.c: Changed header to GPL version 2 only mysys/thr_rwlock.c: Changed header to GPL version 2 only mysys/tree.c: Changed header to GPL version 2 only mysys/typelib.c: Changed header to GPL version 2 only ndb/include/debugger/DebuggerNames.hpp: Changed header to GPL version 2 only ndb/include/debugger/EventLogger.hpp: Changed header to GPL version 2 only ndb/include/debugger/GrepError.hpp: Changed header to GPL version 2 only ndb/include/debugger/SignalLoggerManager.hpp: Changed header to GPL version 2 only ndb/include/editline/editline.h: Changed header to GPL version 2 only ndb/include/kernel/AttributeDescriptor.hpp: Changed header to GPL version 2 only ndb/include/kernel/AttributeHeader.hpp: Changed header to GPL version 2 only ndb/include/kernel/AttributeList.hpp: Changed header to GPL version 2 only ndb/include/kernel/BlockNumbers.h: Changed header to GPL version 2 only ndb/include/kernel/GlobalSignalNumbers.h: Changed header to GPL version 2 only ndb/include/kernel/GrepEvent.hpp: Changed header to GPL version 2 only ndb/include/kernel/Interpreter.hpp: Changed header to GPL version 2 only ndb/include/kernel/LogLevel.hpp: Changed header to GPL version 2 only ndb/include/kernel/NodeBitmask.hpp: Changed header to GPL version 2 only ndb/include/kernel/NodeInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/NodeState.hpp: Changed header to GPL version 2 only ndb/include/kernel/RefConvert.hpp: Changed header to GPL version 2 only ndb/include/kernel/kernel_types.h: Changed header to GPL version 2 only ndb/include/kernel/ndb_limits.h: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AbortAll.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AccFrag.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AccLock.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AccScan.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AccSizeAltReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AlterIndx.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AlterTab.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AlterTable.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AlterTrig.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ApiBroadcast.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ApiRegSignalData.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ApiVersion.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ArbitSignalData.hpp: Changed header to GPL version 2 only ndb/include/kernel/trigger_definitions.h: Changed header to GPL version 2 only ndb/include/ndb_constants.h: Changed header to GPL version 2 only ndb/include/ndb_global.h.in: Changed header to GPL version 2 only ndb/include/ndb_init.h: Changed header to GPL version 2 only ndb/include/ndb_types.h.in: Changed header to GPL version 2 only ndb/include/ndb_version.h.in: Changed header to GPL version 2 only ndb/include/kernel/signaldata/AttrInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/BackupContinueB.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/BackupImpl.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/BackupSignalData.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/BlockCommitOrd.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/BuildIndx.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CheckNodeGroups.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CloseComReqConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CmInit.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CmRegSignalData.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CmvmiCfgConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CntrMasterConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CntrMasterReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ConfigParamId.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ContinueFragmented.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CopyActive.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CopyFrag.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CopyGCIReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CreateEvnt.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CreateFrag.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CreateFragmentation.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CreateIndx.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CreateTab.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CreateTable.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/CreateTrig.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DiAddTab.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DiGetNodes.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DictLock.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DictSchemaInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DictSizeAltReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DictStart.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DictTabInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DihAddFrag.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DihContinueB.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DihSizeAltReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DihStartTab.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DihSwitchReplica.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DisconnectRep.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DropIndx.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DropTab.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DropTabFile.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DropTable.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DropTrig.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/DumpStateOrd.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/EmptyLcp.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/EndTo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/EventReport.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/EventSubscribeReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ExecFragReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/FailRep.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/FireTrigOrd.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/FsAppendReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/FsCloseReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/FsConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/FsOpenReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/FsReadWriteReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/FsRef.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/FsRemoveReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/GCPSave.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/GetTabInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/GetTableId.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/GrepImpl.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/HotSpareRep.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/IndxAttrInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/IndxKeyInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/InvalidateNodeLCPConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/InvalidateNodeLCPReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/KeyInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/LCP.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ListTables.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/LqhFrag.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/LqhKey.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/LqhSizeAltReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/LqhTransConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ManagementServer.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/MasterGCP.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/MasterLCP.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/NFCompleteRep.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/NdbSttor.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/NdbfsContinueB.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/NextScan.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/NodeFailRep.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/NodeStateSignalData.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/PackedSignal.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/PrepDropTab.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/PrepFailReqRef.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ReadNodesConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/RelTabMem.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/RepImpl.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ResumeReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ScanFrag.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/ScanTab.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/SetLogLevelOrd.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/SetVarReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/SignalData.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/SignalDataPrint.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/SignalDroppedRep.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/SrFragidConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StartFragReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StartInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StartMe.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StartOrd.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StartPerm.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StartRec.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StartTo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StopMe.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StopPerm.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/StopReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/SumaImpl.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/SystemError.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TamperOrd.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcCommit.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcContinueB.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcHbRep.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcIndx.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcKeyConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcKeyFailConf.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcKeyRef.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcKeyReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcRollbackRep.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TcSizeAltReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TestOrd.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TransIdAI.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TrigAttrInfo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TupCommit.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TupFrag.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TupKey.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TupSizeAltReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TuxBound.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TuxContinueB.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TuxMaint.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/TuxSizeAltReq.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/UpdateTo.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/UtilDelete.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/UtilExecute.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/UtilLock.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/UtilPrepare.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/UtilRelease.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/UtilSequence.hpp: Changed header to GPL version 2 only ndb/include/kernel/signaldata/WaitGCP.hpp: Changed header to GPL version 2 only ndb/include/logger/ConsoleLogHandler.hpp: Changed header to GPL version 2 only ndb/include/logger/FileLogHandler.hpp: Changed header to GPL version 2 only ndb/include/logger/LogHandler.hpp: Changed header to GPL version 2 only ndb/include/logger/Logger.hpp: Changed header to GPL version 2 only ndb/include/logger/SysLogHandler.hpp: Changed header to GPL version 2 only ndb/include/mgmapi/mgmapi.h: Changed header to GPL version 2 only ndb/include/mgmapi/mgmapi_debug.h: Changed header to GPL version 2 only ndb/include/mgmapi/ndb_logevent.h: Changed header to GPL version 2 only ndb/include/mgmapi/ndbd_exit_codes.h: Changed header to GPL version 2 only ndb/include/mgmcommon/ConfigRetriever.hpp: Changed header to GPL version 2 only ndb/include/mgmcommon/IPCConfig.hpp: Changed header to GPL version 2 only ndb/include/mgmcommon/MgmtErrorReporter.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/Ndb.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbApi.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbBlob.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbDictionary.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbError.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbEventOperation.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbIndexOperation.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbIndexScanOperation.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbOperation.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbPool.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbRecAttr.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbReceiver.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbScanFilter.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbScanOperation.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/NdbTransaction.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/ndb_cluster_connection.hpp: Changed header to GPL version 2 only ndb/include/ndbapi/ndb_opt_defaults.h: Changed header to GPL version 2 only ndb/include/ndbapi/ndbapi_limits.h: Changed header to GPL version 2 only ndb/include/ndbapi/ndberror.h: Changed header to GPL version 2 only ndb/include/newtonapi/dba.h: Changed header to GPL version 2 only ndb/include/newtonapi/defs/pcn_types.h: Changed header to GPL version 2 only ndb/include/portlib/NdbCondition.h: Changed header to GPL version 2 only ndb/include/portlib/NdbConfig.h: Changed header to GPL version 2 only ndb/include/portlib/NdbDaemon.h: Changed header to GPL version 2 only ndb/include/portlib/NdbEnv.h: Changed header to GPL version 2 only ndb/include/portlib/NdbHost.h: Changed header to GPL version 2 only ndb/include/portlib/NdbMain.h: Changed header to GPL version 2 only ndb/include/portlib/NdbMem.h: Changed header to GPL version 2 only ndb/include/portlib/NdbMutex.h: Changed header to GPL version 2 only ndb/include/portlib/NdbSleep.h: Changed header to GPL version 2 only ndb/include/portlib/NdbTCP.h: Changed header to GPL version 2 only ndb/include/portlib/NdbThread.h: Changed header to GPL version 2 only ndb/include/portlib/NdbTick.h: Changed header to GPL version 2 only ndb/include/portlib/PortDefs.h: Changed header to GPL version 2 only ndb/include/portlib/prefetch.h: Changed header to GPL version 2 only ndb/include/transporter/TransporterCallback.hpp: Changed header to GPL version 2 only ndb/include/transporter/TransporterDefinitions.hpp: Changed header to GPL version 2 only ndb/include/transporter/TransporterRegistry.hpp: Changed header to GPL version 2 only ndb/include/util/BaseString.hpp: Changed header to GPL version 2 only ndb/include/util/Bitmask.hpp: Changed header to GPL version 2 only ndb/include/util/File.hpp: Changed header to GPL version 2 only ndb/include/util/InputStream.hpp: Changed header to GPL version 2 only ndb/include/util/NdbAutoPtr.hpp: Changed header to GPL version 2 only ndb/include/util/NdbOut.hpp: Changed header to GPL version 2 only ndb/include/util/NdbSqlUtil.hpp: Changed header to GPL version 2 only ndb/include/util/OutputStream.hpp: Changed header to GPL version 2 only ndb/include/util/Parser.hpp: Changed header to GPL version 2 only ndb/include/util/Properties.hpp: Changed header to GPL version 2 only ndb/include/util/SimpleProperties.hpp: Changed header to GPL version 2 only ndb/include/util/SocketAuthenticator.hpp: Changed header to GPL version 2 only ndb/include/util/SocketClient.hpp: Changed header to GPL version 2 only ndb/include/util/SocketServer.hpp: Changed header to GPL version 2 only ndb/include/util/UtilBuffer.hpp: Changed header to GPL version 2 only ndb/include/util/Vector.hpp: Changed header to GPL version 2 only ndb/include/util/basestring_vsnprintf.h: Changed header to GPL version 2 only ndb/include/util/md5_hash.hpp: Changed header to GPL version 2 only ndb/include/util/ndb_opts.h: Changed header to GPL version 2 only ndb/include/util/random.h: Changed header to GPL version 2 only ndb/include/util/socket_io.h: Changed header to GPL version 2 only ndb/include/util/uucode.h: Changed header to GPL version 2 only ndb/include/util/version.h: Changed header to GPL version 2 only ndb/ndbapi-examples/mgmapi_logevent_example/mgmapi_logevent.cpp: Changed header to GPL version 2 only ndb/ndbapi-examples/ndbapi_async_example/ndbapi_async.cpp: Changed header to GPL version 2 only ndb/ndbapi-examples/ndbapi_async_example1/ndbapi_async1.cpp: Changed header to GPL version 2 only ndb/ndbapi-examples/ndbapi_event_example/ndbapi_event.cpp: Changed header to GPL version 2 only ndb/ndbapi-examples/ndbapi_retries_example/ndbapi_retries.cpp: Changed header to GPL version 2 only ndb/ndbapi-examples/ndbapi_scan_example/ndbapi_scan.cpp: Changed header to GPL version 2 only ndb/ndbapi-examples/ndbapi_simple_example/ndbapi_simple.cpp: Changed header to GPL version 2 only ndb/ndbapi-examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/BlockNames.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/DebuggerNames.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/EventLogger.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/GrepError.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/SignalLoggerManager.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/AccLock.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/AlterIndx.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/AlterTab.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/AlterTable.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/AlterTrig.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/BackupImpl.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/BackupSignalData.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/CloseComReqConf.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/ContinueB.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/CopyGCI.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/CreateEvnt.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/CreateFragmentation.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/CreateIndx.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/CreateTrig.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/DictTabInfo.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/DihContinueB.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/DihSwitchReplicaReq.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/DisconnectRep.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/DropIndx.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/DropTab.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/DropTrig.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/FailRep.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/FireTrigOrd.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/FsAppendReq.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/FsCloseReq.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/FsConf.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/FsOpenReq.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/FsRef.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/GCPSave.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/IndxAttrInfo.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/IndxKeyInfo.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/LCP.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/LqhFrag.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/LqhKey.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/LqhTrans.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/MasterLCP.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/NFCompleteRep.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/NdbSttor.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/NdbfsContinueB.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/PackedSignal.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/PrepDropTab.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/PrepFailReqRef.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/ScanFrag.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/ScanTab.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/SignalDataPrint.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/SignalDroppedRep.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/SignalNames.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/StartRec.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/SumaImpl.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/SystemError.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/TcIndx.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/TcKeyConf.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/TcKeyRef.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/TcKeyReq.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/TcRollbackRep.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/TrigAttrInfo.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/TupCommit.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/TupKey.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/TuxMaint.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/UtilDelete.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/UtilExecute.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/UtilLock.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/UtilPrepare.cpp: Changed header to GPL version 2 only ndb/src/common/debugger/signaldata/UtilSequence.cpp: Changed header to GPL version 2 only ndb/src/common/logger/ConsoleLogHandler.cpp: Changed header to GPL version 2 only ndb/src/common/logger/FileLogHandler.cpp: Changed header to GPL version 2 only ndb/src/common/logger/LogHandler.cpp: Changed header to GPL version 2 only ndb/src/common/logger/LogHandlerList.cpp: Changed header to GPL version 2 only ndb/src/common/logger/LogHandlerList.hpp: Changed header to GPL version 2 only ndb/src/common/logger/Logger.cpp: Changed header to GPL version 2 only ndb/src/common/logger/SysLogHandler.cpp: Changed header to GPL version 2 only ndb/src/common/logger/listtest/LogHandlerListUnitTest.cpp: Changed header to GPL version 2 only ndb/src/common/logger/listtest/LogHandlerListUnitTest.hpp: Changed header to GPL version 2 only ndb/src/common/logger/loggertest/LoggerUnitTest.cpp: Changed header to GPL version 2 only ndb/src/common/logger/loggertest/LoggerUnitTest.hpp: Changed header to GPL version 2 only ndb/src/common/mgmcommon/ConfigRetriever.cpp: Changed header to GPL version 2 only ndb/src/common/mgmcommon/IPCConfig.cpp: Changed header to GPL version 2 only ndb/src/common/mgmcommon/printConfig/printConfig.cpp: Changed header to GPL version 2 only ndb/src/common/portlib/NdbCondition.c: Changed header to GPL version 2 only ndb/src/common/portlib/NdbConfig.c: Changed header to GPL version 2 only ndb/src/common/portlib/NdbDaemon.c: Changed header to GPL version 2 only ndb/src/common/portlib/NdbEnv.c: Changed header to GPL version 2 only ndb/src/common/portlib/NdbHost.c: Changed header to GPL version 2 only ndb/src/common/portlib/NdbMem.c: Changed header to GPL version 2 only ndb/src/common/portlib/NdbMutex.c: Changed header to GPL version 2 only ndb/src/common/portlib/NdbPortLibTest.cpp: Changed header to GPL version 2 only ndb/src/common/portlib/NdbSleep.c: Changed header to GPL version 2 only ndb/src/common/portlib/NdbTCP.cpp: Changed header to GPL version 2 only ndb/src/common/portlib/NdbThread.c: Changed header to GPL version 2 only ndb/src/common/portlib/NdbTick.c: Changed header to GPL version 2 only ndb/src/common/portlib/memtest.c: Changed header to GPL version 2 only ndb/src/common/portlib/mmslist.cpp: Changed header to GPL version 2 only ndb/src/common/portlib/mmstest.cpp: Changed header to GPL version 2 only ndb/src/common/portlib/munmaptest.cpp: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbCondition.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbConditionOSE.h: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbEnv.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbHost.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbMem.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbMem_SoftOse.cpp: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbMutex.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbOut.cpp: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbSleep.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbTCP.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbThread.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/ose/NdbTick.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbCondition.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbDaemon.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbEnv.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbHost.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbMem.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbMutex.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbSleep.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbTCP.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbThread.c: Changed header to GPL version 2 only ndb/src/common/portlib/old_dirs/win32/NdbTick.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbCondition.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbDaemon.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbEnv.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbHost.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbMem.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbMutex.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbSleep.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbTCP.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbThread.c: Changed header to GPL version 2 only ndb/src/common/portlib/win32/NdbTick.c: Changed header to GPL version 2 only ndb/src/common/transporter/OSE_Receiver.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/OSE_Receiver.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/OSE_Signals.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/OSE_Transporter.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/OSE_Transporter.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/Packer.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/Packer.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/SCI_Transporter.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/SCI_Transporter.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/SHM_Buffer.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/SHM_Transporter.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/SHM_Transporter.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/SHM_Transporter.unix.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/SHM_Transporter.win32.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/SendBuffer.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/SendBuffer.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/TCP_Transporter.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/TCP_Transporter.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/Transporter.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/Transporter.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/TransporterInternalDefinitions.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/TransporterRegistry.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/basictest/basicTransporterTest.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/buddy.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/buddy.hpp: Changed header to GPL version 2 only ndb/src/common/transporter/failoverSCI/failoverSCI.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/perftest/perfTransporterTest.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/priotest/prioSCI/prioSCI.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/priotest/prioSHM/prioSHM.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/priotest/prioTCP/prioTCP.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/priotest/prioTransporterTest.cpp: Changed header to GPL version 2 only ndb/src/common/transporter/priotest/prioTransporterTest.hpp: Changed header to GPL version 2 only ndb/src/common/util/BaseString.cpp: Changed header to GPL version 2 only ndb/src/common/util/File.cpp: Changed header to GPL version 2 only ndb/src/common/util/InputStream.cpp: Changed header to GPL version 2 only ndb/src/common/util/NdbErrHnd.cpp: Changed header to GPL version 2 only ndb/src/common/util/NdbOut.cpp: Changed header to GPL version 2 only ndb/src/common/util/NdbSqlUtil.cpp: Changed header to GPL version 2 only ndb/src/common/util/OutputStream.cpp: Changed header to GPL version 2 only ndb/src/common/util/Parser.cpp: Changed header to GPL version 2 only ndb/src/common/util/Properties.cpp: Changed header to GPL version 2 only ndb/src/common/util/SimpleProperties.cpp: Changed header to GPL version 2 only ndb/src/common/util/SocketAuthenticator.cpp: Changed header to GPL version 2 only ndb/src/common/util/SocketClient.cpp: Changed header to GPL version 2 only ndb/src/common/util/SocketServer.cpp: Changed header to GPL version 2 only ndb/src/common/util/basestring_vsnprintf.c: Changed header to GPL version 2 only ndb/src/common/util/filetest/FileUnitTest.cpp: Changed header to GPL version 2 only ndb/src/common/util/filetest/FileUnitTest.hpp: Changed header to GPL version 2 only ndb/src/common/util/md5_hash.cpp: Changed header to GPL version 2 only ndb/src/common/util/ndb_init.c: Changed header to GPL version 2 only ndb/src/common/util/random.c: Changed header to GPL version 2 only ndb/src/common/util/socket_io.cpp: Changed header to GPL version 2 only ndb/src/common/util/strdup.c: Changed header to GPL version 2 only ndb/src/common/util/testProperties/testProperties.cpp: Changed header to GPL version 2 only ndb/src/common/util/testSimpleProperties/sp_test.cpp: Changed header to GPL version 2 only ndb/src/common/util/uucode.c: Changed header to GPL version 2 only ndb/src/common/util/version.c: Changed header to GPL version 2 only ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp: Changed header to GPL version 2 only ndb/src/cw/cpcc-win32/C++/CPC_GUI.h: Changed header to GPL version 2 only ndb/src/cw/cpcc-win32/C++/NdbControls.cpp: Changed header to GPL version 2 only ndb/src/cw/cpcc-win32/C++/StdAfx.cpp: Changed header to GPL version 2 only ndb/src/cw/cpcc-win32/C++/StdAfx.h: Changed header to GPL version 2 only ndb/src/cw/cpcc-win32/C++/TreeView.cpp: Changed header to GPL version 2 only ndb/src/cw/cpcc-win32/C++/TreeView.h: Changed header to GPL version 2 only ndb/src/cw/cpcc-win32/C++/resource.h: Changed header to GPL version 2 only ndb/src/cw/cpcd/APIService.cpp: Changed header to GPL version 2 only ndb/src/cw/cpcd/APIService.hpp: Changed header to GPL version 2 only ndb/src/cw/cpcd/CPCD.cpp: Changed header to GPL version 2 only ndb/src/cw/cpcd/CPCD.hpp: Changed header to GPL version 2 only ndb/src/cw/cpcd/Monitor.cpp: Changed header to GPL version 2 only ndb/src/cw/cpcd/Process.cpp: Changed header to GPL version 2 only ndb/src/cw/cpcd/common.cpp: Changed header to GPL version 2 only ndb/src/cw/cpcd/common.hpp: Changed header to GPL version 2 only ndb/src/cw/cpcd/main.cpp: Changed header to GPL version 2 only ndb/src/cw/test/socketclient/socketClientTest.cpp: Changed header to GPL version 2 only ndb/src/cw/util/ClientInterface.cpp: Changed header to GPL version 2 only ndb/src/cw/util/ClientInterface.hpp: Changed header to GPL version 2 only ndb/src/cw/util/SocketRegistry.cpp: Changed header to GPL version 2 only ndb/src/cw/util/SocketRegistry.hpp: Changed header to GPL version 2 only ndb/src/cw/util/SocketService.cpp: Changed header to GPL version 2 only ndb/src/cw/util/SocketService.hpp: Changed header to GPL version 2 only ndb/src/kernel/SimBlockList.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/backup/Backup.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/backup/Backup.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/backup/BackupFormat.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/backup/BackupInit.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/backup/FsBuffer.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/backup/read.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbacc/Dbacc.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbacc/DbaccInit.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbacc/DbaccMain.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/mutexes.hpp: Changed header to GPL version 2 only ndb/src/kernel/main.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbdict/SchemaFile.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbdih/DbdihInit.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbdih/Sysfile.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbdih/printSysfile/printSysfile.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dblqh/DblqhInit.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dblqh/redoLogReader/records.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dblqh/redoLogReader/records.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dblqh/redoLogReader/redoLogFileReader.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtc/DbtcInit.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/AttributeOffset.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupAbort.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupBuffer.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupGen.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupLCP.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupPagMan.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupSystemRestart.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtup/DbtupUndoLog.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/Dbtux.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbutil/DbUtil.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/dbutil/DbUtil.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbcntr/NdbcntrSysTable.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/AsyncFileTest/AsyncFileTest.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/CircularIndex.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/CircularIndex.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/Filename.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/Filename.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/MemoryChannel.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/MemoryChannelOSE.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/OpenFiles.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/Pool.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/ndbfs/VoidFs.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/qmgr/QmgrInit.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/qmgr/timer.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/suma/Suma.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/suma/Suma.hpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/suma/SumaInit.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/trix/Trix.cpp: Changed header to GPL version 2 only ndb/src/kernel/blocks/trix/Trix.hpp: Changed header to GPL version 2 only ndb/src/kernel/error/ErrorHandlingMacros.hpp: Changed header to GPL version 2 only ndb/src/kernel/error/ErrorReporter.cpp: Changed header to GPL version 2 only ndb/src/kernel/error/ErrorReporter.hpp: Changed header to GPL version 2 only ndb/src/kernel/error/TimeModule.cpp: Changed header to GPL version 2 only ndb/src/kernel/error/TimeModule.hpp: Changed header to GPL version 2 only ndb/src/kernel/error/ndbd_exit_codes.c: Changed header to GPL version 2 only ndb/src/kernel/vm/Array.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/ArrayFifoList.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/ArrayList.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/ArrayPool.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/CArray.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/Callback.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/ClusterConfiguration.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/ClusterConfiguration.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/Configuration.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/Configuration.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/DLFifoList.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/DLHashTable.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/DLHashTable2.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/DLList.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/DataBuffer.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/Emulator.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/Emulator.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/FastScheduler.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/FastScheduler.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/GlobalData.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/KeyDescriptor.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/KeyTable.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/KeyTable2.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/LongSignal.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/MetaData.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/MetaData.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/Mutex.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/Mutex.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/Prio.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/RequestTracker.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SLList.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SafeCounter.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SafeCounter.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SectionReader.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SectionReader.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SignalCounter.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SimBlockList.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SimplePropertiesSection.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SimulatedBlock.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SimulatedBlock.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SuperPool.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/SuperPool.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/ThreadConfig.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/ThreadConfig.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/TimeQueue.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/TimeQueue.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/TransporterCallback.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/VMSignal.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/VMSignal.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/WaitQueue.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/WatchDog.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/WatchDog.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/al_test/arrayListTest.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/al_test/arrayPoolTest.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/al_test/main.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/ndbd_malloc.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/ndbd_malloc.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/pc.hpp: Changed header to GPL version 2 only ndb/src/kernel/vm/testCopy/rr.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/testCopy/testCopy.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/testLongSig/testLongSig.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/testSimplePropertiesSection/test.cpp: Changed header to GPL version 2 only ndb/src/kernel/vm/testSuperPool.cpp: Changed header to GPL version 2 only ndb/src/mgmapi/LocalConfig.cpp: Changed header to GPL version 2 only ndb/src/mgmapi/LocalConfig.hpp: Changed header to GPL version 2 only ndb/src/mgmapi/mgmapi.cpp: Changed header to GPL version 2 only ndb/src/mgmapi/mgmapi_configuration.hpp: Changed header to GPL version 2 only ndb/src/mgmapi/mgmapi_internal.h: Changed header to GPL version 2 only ndb/src/mgmapi/ndb_logevent.cpp: Changed header to GPL version 2 only ndb/src/mgmapi/ndb_logevent.hpp: Changed header to GPL version 2 only ndb/src/mgmapi/test/keso.c: Changed header to GPL version 2 only ndb/src/mgmapi/test/mgmSrvApi.cpp: Changed header to GPL version 2 only ndb/src/mgmclient/CommandInterpreter.cpp: Changed header to GPL version 2 only ndb/src/mgmclient/main.cpp: Changed header to GPL version 2 only ndb/src/mgmclient/ndb_mgmclient.hpp: Changed header to GPL version 2 only ndb/src/mgmclient/ndb_mgmclient.h: Changed header to GPL version 2 only ndb/src/mgmclient/test_cpcd/test_cpcd.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/Config.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/Config.hpp: Changed header to GPL version 2 only ndb/src/mgmsrv/ConfigInfo.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/ConfigInfo.hpp: Changed header to GPL version 2 only ndb/src/mgmsrv/InitConfigFileParser.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/InitConfigFileParser.hpp: Changed header to GPL version 2 only ndb/src/mgmsrv/MgmtSrvr.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/MgmtSrvr.hpp: Changed header to GPL version 2 only ndb/src/mgmsrv/MgmtSrvrConfig.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/MgmtSrvrGeneralSignalHandling.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/Services.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/Services.hpp: Changed header to GPL version 2 only ndb/src/mgmsrv/SignalQueue.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/SignalQueue.hpp: Changed header to GPL version 2 only ndb/src/mgmsrv/convertStrToInt.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/convertStrToInt.hpp: Changed header to GPL version 2 only ndb/src/mgmsrv/main.cpp: Changed header to GPL version 2 only ndb/src/mgmsrv/mkconfig/mkconfig.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/API.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/ClusterMgr.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/ClusterMgr.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/DictCache.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/DictCache.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/Ndb.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbApiSignal.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbApiSignal.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbBlob.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbBlobImpl.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbDictionary.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbDictionaryImpl.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbDictionaryImpl.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbErrorOut.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbEventOperation.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbEventOperationImpl.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbEventOperationImpl.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbImpl.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbIndexOperation.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbLinHash.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbOperation.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbOperationDefine.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbOperationExec.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbOperationInt.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbOperationScan.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbOperationSearch.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbPool.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbPoolImpl.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbPoolImpl.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbRecAttr.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbReceiver.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbScanFilter.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbScanOperation.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbTransaction.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbTransactionScan.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbUtil.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbUtil.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/NdbWaiter.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/Ndberr.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/Ndbif.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/Ndbinit.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/Ndblist.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/ObjectMap.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/SignalSender.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/SignalSender.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/TransporterFacade.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/TransporterFacade.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/ndb_cluster_connection.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/ndb_cluster_connection_impl.hpp: Changed header to GPL version 2 only ndb/src/ndbapi/ndberror.c: Changed header to GPL version 2 only ndb/src/ndbapi/signal-sender/SignalSender.cpp: Changed header to GPL version 2 only ndb/src/ndbapi/signal-sender/SignalSender.hpp: Changed header to GPL version 2 only ndb/test/include/CpcClient.hpp: Changed header to GPL version 2 only ndb/test/include/HugoAsynchTransactions.hpp: Changed header to GPL version 2 only ndb/test/include/HugoCalculator.hpp: Changed header to GPL version 2 only ndb/test/include/HugoOperations.hpp: Changed header to GPL version 2 only ndb/test/include/HugoTransactions.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT_DataSet.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT_DataSetTransaction.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT_Error.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT_Output.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT_ResultRow.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT_ReturnCodes.h: Changed header to GPL version 2 only ndb/test/include/NDBT_Stats.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT_Table.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT_Tables.hpp: Changed header to GPL version 2 only ndb/test/include/NDBT_Test.hpp: Changed header to GPL version 2 only ndb/test/include/NdbBackup.hpp: Changed header to GPL version 2 only ndb/test/include/NdbConfig.hpp: Changed header to GPL version 2 only ndb/test/include/NdbGrep.hpp: Changed header to GPL version 2 only ndb/test/include/NdbRestarter.hpp: Changed header to GPL version 2 only ndb/test/include/NdbRestarts.hpp: Changed header to GPL version 2 only ndb/test/include/NdbSchemaCon.hpp: Changed header to GPL version 2 only ndb/test/include/NdbSchemaOp.hpp: Changed header to GPL version 2 only ndb/test/include/NdbTest.hpp: Changed header to GPL version 2 only ndb/test/include/NdbTimer.hpp: Changed header to GPL version 2 only ndb/test/include/TestNdbEventOperation.hpp: Changed header to GPL version 2 only ndb/test/include/UtilTransactions.hpp: Changed header to GPL version 2 only ndb/test/include/getarg.h: Changed header to GPL version 2 only ndb/test/ndbapi/InsertRecs.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ScanFilter.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/ScanFunctions.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/ScanInterpretTest.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/TraceNdbApi.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/VerifyNdbApi.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/acid.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/acid2.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/adoInsertRecs.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/asyncGenerator.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/benchronja.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bulk_copy.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/cdrserver.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/celloDb.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/create_all_tabs.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/create_tab.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/drop_all_tabs.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/flexAsynch.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/flexBench.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/flexHammer.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/flexScan.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/flexTT.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/flexTimedAsynch.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/flex_bench_mysql.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/index.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/index2.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/initronja.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/interpreterInTup.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/mainAsyncGenerator.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/msa.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ndb_async1.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ndb_async2.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ndb_user_populate.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ndb_user_transaction.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ndb_user_transaction2.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ndb_user_transaction3.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ndb_user_transaction4.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ndb_user_transaction5.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/ndb_user_transaction6.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/restarter.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/restarter2.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/restarts.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/size.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testBackup.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testBasic.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testBasicAsynch.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testBlobs.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testDataBuffers.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testDeadlock.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testDict.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testGrepVerify.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testIndex.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testInterpreter.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testMgm.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testNdbApi.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testNodeRestart.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testOIBasic.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testOperations.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testOrderedIndex.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testPartitioning.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testReadPerf.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testRestartGci.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testSRBank.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testScan.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testScanInterpreter.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testScanPerf.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testSystemRestart.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/Bank.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/Bank.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/BankLoad.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/bankCreator.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/bankMakeGL.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/bankSumAccounts.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/bankTimer.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/bankTransactionMaker.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/bankValidateAllGLs.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bank/testBank.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/asyncGenerator.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/dbGenerator.h: Changed header to GPL version 2 only ndb/test/ndbapi/bench/dbPopulate.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/dbPopulate.h: Changed header to GPL version 2 only ndb/test/ndbapi/bench/macros.h: Changed header to GPL version 2 only ndb/test/ndbapi/bench/mainAsyncGenerator.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/mainPopulate.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_async1.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_async2.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_error.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_schema.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_user_transaction.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_user_transaction2.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_user_transaction3.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_user_transaction4.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_user_transaction5.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/ndb_user_transaction6.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/testData.h: Changed header to GPL version 2 only ndb/test/ndbapi/bench/testDefinitions.h: Changed header to GPL version 2 only ndb/test/ndbapi/bench/userInterface.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/bench/userInterface.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/acid2/TraceNdbApi.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/acid2/VerifyNdbApi.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/dbGenerator.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/testData.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/userInterface.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/macros.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/ndb_error.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/include/ndb_schema.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/include/testDefinitions.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.c: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/mainGenerator.c: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/include/testData.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/include/userInterface.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.c: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/mainPopulate.c: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/user/localDbPrepare.c: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/user/macros.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/user/ndb_error.hpp: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userHandle.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userInterface.c: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userHandle.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userInterface.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userTransaction.c: Changed header to GPL version 2 only ndb/test/ndbapi/testTimeout.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/testTransactions.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/test_event.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/test_event_merge.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/test_event_multi_table.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/userInterface.cpp: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userTransaction.c: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/vw_test/bcd.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/vw_test/utv.h: Changed header to GPL version 2 only ndb/test/ndbapi/old_dirs/vw_test/vcdrfunc.h: Changed header to GPL version 2 only ndb/test/newtonapi/basic_test/basic/basic.cpp: Changed header to GPL version 2 only ndb/test/newtonapi/basic_test/bulk_read/br_test.cpp: Changed header to GPL version 2 only ndb/test/newtonapi/basic_test/common.cpp: Changed header to GPL version 2 only ndb/test/newtonapi/basic_test/common.hpp: Changed header to GPL version 2 only ndb/test/newtonapi/basic_test/ptr_binding/ptr_binding_test.cpp: Changed header to GPL version 2 only ndb/test/newtonapi/basic_test/too_basic.cpp: Changed header to GPL version 2 only ndb/test/newtonapi/perf_test/perf.cpp: Changed header to GPL version 2 only ndb/test/odbc/SQL99_test/SQL99_test.cpp: Changed header to GPL version 2 only ndb/test/odbc/SQL99_test/SQL99_test.h: Changed header to GPL version 2 only ndb/test/odbc/client/NDBT_ALLOCHANDLE.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/NDBT_ALLOCHANDLE_HDBC.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/NDBT_SQLConnect.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/NDBT_SQLPrepare.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLAllocEnvTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLAllocHandleTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLAllocHandleTest_bf.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLBindColTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLBindParameterTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLCancelTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLCloseCursorTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLColAttributeTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLColAttributeTest1.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLColAttributeTest2.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLColAttributeTest3.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLConnectTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLCopyDescTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLDescribeColTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLDisconnectTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLDriverConnectTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLEndTranTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLErrorTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLExecDirectTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLExecuteTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLFetchScrollTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLFetchTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLFreeHandleTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLFreeStmtTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetConnectAttrTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetCursorNameTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetDataTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetDescFieldTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetDescRecTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetDiagFieldTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetDiagRecSimpleTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetDiagRecTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetEnvAttrTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetFunctionsTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetInfoTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetStmtAttrTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLGetTypeInfoTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLMoreResultsTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLNumResultColsTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLParamDataTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLPrepareTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLPutDataTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLRowCountTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLSetConnectAttrTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLSetCursorNameTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLSetDescFieldTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLSetDescRecTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLSetEnvAttrTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLSetStmtAttrTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLTablesTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/SQLTransactTest.cpp: Changed header to GPL version 2 only ndb/test/odbc/client/common.hpp: Changed header to GPL version 2 only ndb/test/odbc/client/main.cpp: Changed header to GPL version 2 only ndb/test/odbc/driver/testOdbcDriver.cpp: Changed header to GPL version 2 only ndb/test/odbc/test_compiler/test_compiler.cpp: Changed header to GPL version 2 only ndb/test/run-test/main.cpp: Changed header to GPL version 2 only ndb/test/run-test/run-test.hpp: Changed header to GPL version 2 only ndb/test/src/CpcClient.cpp: Changed header to GPL version 2 only ndb/test/src/HugoAsynchTransactions.cpp: Changed header to GPL version 2 only ndb/test/src/HugoCalculator.cpp: Changed header to GPL version 2 only ndb/test/src/HugoOperations.cpp: Changed header to GPL version 2 only ndb/test/src/HugoTransactions.cpp: Changed header to GPL version 2 only ndb/test/src/NDBT_Error.cpp: Changed header to GPL version 2 only ndb/test/src/NDBT_Output.cpp: Changed header to GPL version 2 only ndb/test/src/NDBT_ResultRow.cpp: Changed header to GPL version 2 only ndb/test/src/NDBT_ReturnCodes.cpp: Changed header to GPL version 2 only ndb/test/src/NDBT_Table.cpp: Changed header to GPL version 2 only ndb/test/src/NDBT_Tables.cpp: Changed header to GPL version 2 only ndb/test/src/NDBT_Test.cpp: Changed header to GPL version 2 only ndb/test/src/NdbBackup.cpp: Changed header to GPL version 2 only ndb/test/src/NdbConfig.cpp: Changed header to GPL version 2 only ndb/test/src/NdbGrep.cpp: Changed header to GPL version 2 only ndb/test/src/NdbRestarter.cpp: Changed header to GPL version 2 only ndb/test/src/NdbRestarts.cpp: Changed header to GPL version 2 only ndb/test/src/NdbSchemaCon.cpp: Changed header to GPL version 2 only ndb/test/src/NdbSchemaOp.cpp: Changed header to GPL version 2 only ndb/test/src/UtilTransactions.cpp: Changed header to GPL version 2 only ndb/test/tools/copy_tab.cpp: Changed header to GPL version 2 only ndb/test/tools/cpcc.cpp: Changed header to GPL version 2 only ndb/test/tools/create_index.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoCalculator.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoFill.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoLoad.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoLockRecords.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoPkDelete.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoPkRead.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoPkReadRecord.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoPkUpdate.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoScanRead.cpp: Changed header to GPL version 2 only ndb/test/tools/hugoScanUpdate.cpp: Changed header to GPL version 2 only ndb/test/tools/old_dirs/waiter/waiter.cpp: Changed header to GPL version 2 only ndb/test/tools/restart.cpp: Changed header to GPL version 2 only ndb/test/tools/transproxy.cpp: Changed header to GPL version 2 only ndb/test/tools/verify_index.cpp: Changed header to GPL version 2 only ndb/tools/delete_all.cpp: Changed header to GPL version 2 only ndb/tools/desc.cpp: Changed header to GPL version 2 only ndb/tools/drop_index.cpp: Changed header to GPL version 2 only ndb/tools/drop_tab.cpp: Changed header to GPL version 2 only ndb/tools/listTables.cpp: Changed header to GPL version 2 only ndb/tools/ndb_config.cpp: Changed header to GPL version 2 only ndb/tools/ndb_test_platform.cpp: Changed header to GPL version 2 only ndb/tools/ndbsql.cpp: Changed header to GPL version 2 only ndb/tools/restore/Restore.cpp: Changed header to GPL version 2 only ndb/tools/restore/Restore.hpp: Changed header to GPL version 2 only ndb/tools/restore/consumer.cpp: Changed header to GPL version 2 only ndb/tools/restore/consumer.hpp: Changed header to GPL version 2 only ndb/tools/restore/consumer_printer.cpp: Changed header to GPL version 2 only ndb/tools/restore/consumer_printer.hpp: Changed header to GPL version 2 only ndb/tools/restore/consumer_restore.cpp: Changed header to GPL version 2 only ndb/tools/restore/consumer_restore.hpp: Changed header to GPL version 2 only ndb/tools/select_all.cpp: Changed header to GPL version 2 only ndb/tools/select_count.cpp: Changed header to GPL version 2 only ndb/tools/waiter.cpp: Changed header to GPL version 2 only ndb/tools/restore/consumer_restorem.cpp: Changed header to GPL version 2 only ndb/tools/restore/restore_main.cpp: Changed header to GPL version 2 only netware/mysql_fix_privilege_tables.pl: Changed header to GPL version 2 only netware/mysql_secure_installation.pl: Changed header to GPL version 2 only os2/Makefile.am: Changed header to GPL version 2 only os2/include/Makefile.am: Changed header to GPL version 2 only os2/include/sys/Makefile.am: Changed header to GPL version 2 only pstack/Makefile.am: Changed header to GPL version 2 only regex/Makefile.am: Changed header to GPL version 2 only scripts/Makefile.am: Changed header to GPL version 2 only scripts/fill_help_tables.sh: Changed header to GPL version 2 only scripts/mysql_config.sh: Changed header to GPL version 2 only scripts/mysql_secure_installation.sh: Changed header to GPL version 2 only server-tools/instance-manager/Makefile.am: Changed header to GPL version 2 only server-tools/instance-manager/buffer.cc: Changed header to GPL version 2 only server-tools/instance-manager/buffer.h: Changed header to GPL version 2 only server-tools/instance-manager/command.cc: Changed header to GPL version 2 only server-tools/instance-manager/command.h: Changed header to GPL version 2 only server-tools/instance-manager/commands.cc: Changed header to GPL version 2 only server-tools/instance-manager/commands.h: Changed header to GPL version 2 only server-tools/instance-manager/guardian.cc: Changed header to GPL version 2 only server-tools/instance-manager/guardian.h: Changed header to GPL version 2 only server-tools/instance-manager/instance.cc: Changed header to GPL version 2 only server-tools/instance-manager/instance.h: Changed header to GPL version 2 only server-tools/instance-manager/instance_map.cc: Changed header to GPL version 2 only server-tools/instance-manager/instance_map.h: Changed header to GPL version 2 only server-tools/instance-manager/instance_options.cc: Changed header to GPL version 2 only server-tools/instance-manager/instance_options.h: Changed header to GPL version 2 only server-tools/instance-manager/listener.cc: Changed header to GPL version 2 only server-tools/instance-manager/listener.h: Changed header to GPL version 2 only server-tools/instance-manager/log.cc: Changed header to GPL version 2 only server-tools/instance-manager/log.h: Changed header to GPL version 2 only server-tools/instance-manager/manager.cc: Changed header to GPL version 2 only server-tools/instance-manager/manager.h: Changed header to GPL version 2 only server-tools/instance-manager/messages.cc: Changed header to GPL version 2 only server-tools/instance-manager/messages.h: Changed header to GPL version 2 only server-tools/instance-manager/mysql_connection.cc: Changed header to GPL version 2 only server-tools/instance-manager/mysql_connection.h: Changed header to GPL version 2 only server-tools/instance-manager/mysql_manager_error.h: Changed header to GPL version 2 only server-tools/instance-manager/mysqlmanager.cc: Changed header to GPL version 2 only server-tools/instance-manager/options.cc: Changed header to GPL version 2 only server-tools/instance-manager/options.h: Changed header to GPL version 2 only server-tools/instance-manager/parse.cc: Changed header to GPL version 2 only server-tools/instance-manager/parse.h: Changed header to GPL version 2 only server-tools/instance-manager/parse_output.cc: Changed header to GPL version 2 only server-tools/instance-manager/parse_output.h: Changed header to GPL version 2 only server-tools/instance-manager/priv.cc: Changed header to GPL version 2 only server-tools/instance-manager/priv.h: Changed header to GPL version 2 only server-tools/instance-manager/protocol.cc: Changed header to GPL version 2 only server-tools/instance-manager/protocol.h: Changed header to GPL version 2 only server-tools/instance-manager/thread_registry.cc: Changed header to GPL version 2 only server-tools/instance-manager/thread_registry.h: Changed header to GPL version 2 only server-tools/instance-manager/user_map.cc: Changed header to GPL version 2 only server-tools/instance-manager/user_map.h: Changed header to GPL version 2 only sql/Makefile.am: Changed header to GPL version 2 only sql/client_settings.h: Changed header to GPL version 2 only sql/custom_conf.h: Changed header to GPL version 2 only sql/derror.cc: Changed header to GPL version 2 only sql/des_key_file.cc: Changed header to GPL version 2 only sql/discover.cc: Changed header to GPL version 2 only sql/field.cc: Changed header to GPL version 2 only sql/field.h: Changed header to GPL version 2 only sql/field_conv.cc: Changed header to GPL version 2 only sql/filesort.cc: Changed header to GPL version 2 only sql/frm_crypt.cc: Changed header to GPL version 2 only sql/gen_lex_hash.cc: Changed header to GPL version 2 only sql/gstream.cc: Changed header to GPL version 2 only sql/gstream.h: Changed header to GPL version 2 only sql/ha_archive.cc: Changed header to GPL version 2 only sql/ha_archive.h: Changed header to GPL version 2 only sql/ha_berkeley.cc: Changed header to GPL version 2 only sql/ha_berkeley.h: Changed header to GPL version 2 only sql/ha_blackhole.cc: Changed header to GPL version 2 only sql/ha_blackhole.h: Changed header to GPL version 2 only sql/ha_federated.cc: Changed header to GPL version 2 only sql/ha_federated.h: Changed header to GPL version 2 only sql/ha_heap.cc: Changed header to GPL version 2 only sql/ha_heap.h: Changed header to GPL version 2 only sql/ha_innodb.cc: Changed header to GPL version 2 only sql/ha_innodb.h: Changed header to GPL version 2 only sql/ha_myisam.cc: Changed header to GPL version 2 only sql/ha_myisam.h: Changed header to GPL version 2 only sql/ha_myisammrg.cc: Changed header to GPL version 2 only sql/ha_myisammrg.h: Changed header to GPL version 2 only sql/ha_ndbcluster.cc: Changed header to GPL version 2 only sql/ha_ndbcluster.h: Changed header to GPL version 2 only sql/handler.cc: Changed header to GPL version 2 only sql/handler.h: Changed header to GPL version 2 only sql/hash_filo.cc: Changed header to GPL version 2 only sql/hash_filo.h: Changed header to GPL version 2 only sql/hostname.cc: Changed header to GPL version 2 only sql/init.cc: Changed header to GPL version 2 only sql/item.cc: Changed header to GPL version 2 only sql/item.h: Changed header to GPL version 2 only sql/item_buff.cc: Changed header to GPL version 2 only sql/item_cmpfunc.cc: Changed header to GPL version 2 only sql/item_cmpfunc.h: Changed header to GPL version 2 only sql/item_create.cc: Changed header to GPL version 2 only sql/item_create.h: Changed header to GPL version 2 only sql/item_func.cc: Changed header to GPL version 2 only sql/item_func.h: Changed header to GPL version 2 only sql/item_geofunc.cc: Changed header to GPL version 2 only sql/item_geofunc.h: Changed header to GPL version 2 only sql/item_row.cc: Changed header to GPL version 2 only sql/item_row.h: Changed header to GPL version 2 only sql/item_strfunc.cc: Changed header to GPL version 2 only sql/item_strfunc.h: Changed header to GPL version 2 only sql/item_subselect.cc: Changed header to GPL version 2 only sql/item_subselect.h: Changed header to GPL version 2 only sql/item_sum.cc: Changed header to GPL version 2 only sql/item_sum.h: Changed header to GPL version 2 only sql/item_timefunc.cc: Changed header to GPL version 2 only sql/item_timefunc.h: Changed header to GPL version 2 only sql/item_uniq.cc: Changed header to GPL version 2 only sql/item_uniq.h: Changed header to GPL version 2 only sql/key.cc: Changed header to GPL version 2 only sql/lex.h: Changed header to GPL version 2 only sql/lex_symbol.h: Changed header to GPL version 2 only sql/lock.cc: Changed header to GPL version 2 only sql/log.cc: Changed header to GPL version 2 only sql/log_event.cc: Changed header to GPL version 2 only sql/log_event.h: Changed header to GPL version 2 only sql/matherr.c: Changed header to GPL version 2 only sql/mf_iocache.cc: Changed header to GPL version 2 only sql/my_decimal.cc: Changed header to GPL version 2 only sql/my_decimal.h: Changed header to GPL version 2 only sql/my_lock.c: Changed header to GPL version 2 only sql/mysql_priv.h: Changed header to GPL version 2 only sql/mysqld.cc: Changed header to GPL version 2 only sql/mysqld_suffix.h: Changed header to GPL version 2 only sql/net_serv.cc: Changed header to GPL version 2 only sql/opt_range.cc: Changed header to GPL version 2 only sql/opt_range.h: Changed header to GPL version 2 only sql/opt_sum.cc: Changed header to GPL version 2 only sql/parse_file.cc: Changed header to GPL version 2 only sql/parse_file.h: Changed header to GPL version 2 only sql/password.c: Changed header to GPL version 2 only sql/procedure.cc: Changed header to GPL version 2 only sql/procedure.h: Changed header to GPL version 2 only sql/protocol.cc: Changed header to GPL version 2 only sql/protocol.h: Changed header to GPL version 2 only sql/records.cc: Changed header to GPL version 2 only sql/repl_failsafe.cc: Changed header to GPL version 2 only sql/repl_failsafe.h: Changed header to GPL version 2 only sql/set_var.cc: Changed header to GPL version 2 only sql/set_var.h: Changed header to GPL version 2 only sql/slave.cc: Changed header to GPL version 2 only sql/slave.h: Changed header to GPL version 2 only sql/sp.cc: Changed header to GPL version 2 only sql/sp.h: Changed header to GPL version 2 only sql/sp_cache.cc: Changed header to GPL version 2 only sql/sp_cache.h: Changed header to GPL version 2 only sql/sp_head.cc: Changed header to GPL version 2 only sql/sp_head.h: Changed header to GPL version 2 only sql/sp_pcontext.cc: Changed header to GPL version 2 only sql/sp_pcontext.h: Changed header to GPL version 2 only sql/sp_rcontext.cc: Changed header to GPL version 2 only sql/sp_rcontext.h: Changed header to GPL version 2 only sql/spatial.cc: Changed header to GPL version 2 only sql/spatial.h: Changed header to GPL version 2 only sql/sql_acl.cc: Changed header to GPL version 2 only sql/sql_acl.h: Changed header to GPL version 2 only sql/sql_analyse.cc: Changed header to GPL version 2 only sql/sql_analyse.h: Changed header to GPL version 2 only sql/sql_array.h: Changed header to GPL version 2 only sql/sql_base.cc: Changed header to GPL version 2 only sql/sql_bitmap.h: Changed header to GPL version 2 only sql/sql_cache.cc: Changed header to GPL version 2 only sql/sql_cache.h: Changed header to GPL version 2 only sql/sql_class.cc: Changed header to GPL version 2 only sql/sql_class.h: Changed header to GPL version 2 only sql/sql_client.cc: Changed header to GPL version 2 only sql/sql_crypt.cc: Changed header to GPL version 2 only sql/sql_crypt.h: Changed header to GPL version 2 only sql/sql_cursor.cc: Changed header to GPL version 2 only sql/sql_cursor.h: Changed header to GPL version 2 only sql/sql_db.cc: Changed header to GPL version 2 only sql/sql_delete.cc: Changed header to GPL version 2 only sql/sql_derived.cc: Changed header to GPL version 2 only sql/sql_do.cc: Changed header to GPL version 2 only sql/sql_error.cc: Changed header to GPL version 2 only sql/sql_error.h: Changed header to GPL version 2 only sql/sql_handler.cc: Changed header to GPL version 2 only sql/sql_help.cc: Changed header to GPL version 2 only sql/sql_insert.cc: Changed header to GPL version 2 only sql/sql_lex.cc: Changed header to GPL version 2 only sql/sql_lex.h: Changed header to GPL version 2 only sql/sql_list.cc: Changed header to GPL version 2 only sql/sql_list.h: Changed header to GPL version 2 only sql/sql_load.cc: Changed header to GPL version 2 only sql/sql_locale.cc: Changed header to GPL version 2 only sql/sql_manager.cc: Changed header to GPL version 2 only sql/sql_manager.h: Changed header to GPL version 2 only sql/sql_map.cc: Changed header to GPL version 2 only sql/sql_map.h: Changed header to GPL version 2 only sql/sql_olap.cc: Changed header to GPL version 2 only sql/sql_parse.cc: Changed header to GPL version 2 only sql/sql_prepare.cc: Changed header to GPL version 2 only sql/sql_rename.cc: Changed header to GPL version 2 only sql/sql_repl.cc: Changed header to GPL version 2 only sql/sql_repl.h: Changed header to GPL version 2 only sql/sql_select.cc: Changed header to GPL version 2 only sql/sql_select.h: Changed header to GPL version 2 only sql/sql_show.cc: Changed header to GPL version 2 only sql/sql_sort.h: Changed header to GPL version 2 only sql/sql_state.c: Changed header to GPL version 2 only sql/sql_string.cc: Changed header to GPL version 2 only sql/sql_string.h: Changed header to GPL version 2 only sql/sql_table.cc: Changed header to GPL version 2 only sql/sql_test.cc: Changed header to GPL version 2 only sql/sql_trigger.cc: Changed header to GPL version 2 only sql/sql_trigger.h: Changed header to GPL version 2 only sql/sql_udf.cc: Changed header to GPL version 2 only sql/sql_udf.h: Changed header to GPL version 2 only sql/sql_union.cc: Changed header to GPL version 2 only sql/sql_update.cc: Changed header to GPL version 2 only sql-bench/Makefile.am: Changed header to GPL version 2 only sql-bench/as3ap.sh: Changed header to GPL version 2 only sql-bench/bench-count-distinct.sh: Changed header to GPL version 2 only sql-bench/bench-init.pl.sh: Changed header to GPL version 2 only sql-bench/compare-results.sh: Changed header to GPL version 2 only sql-bench/copy-db.sh: Changed header to GPL version 2 only sql-bench/crash-me.sh: Changed header to GPL version 2 only sql-bench/print-limit-table: Changed header to GPL version 2 only sql-bench/run-all-tests.sh: Changed header to GPL version 2 only sql/examples/ha_example.cc: Changed header to GPL version 2 only sql/examples/ha_example.h: Changed header to GPL version 2 only sql/examples/ha_tina.cc: Changed header to GPL version 2 only sql/examples/ha_tina.h: Changed header to GPL version 2 only sql/share/Makefile.am: Changed header to GPL version 2 only sql/share/charsets/Index.xml: Changed header to GPL version 2 only sql/share/charsets/armscii8.xml: Changed header to GPL version 2 only sql/share/charsets/ascii.xml: Changed header to GPL version 2 only sql/share/charsets/cp1250.xml: Changed header to GPL version 2 only sql/share/charsets/cp1251.xml: Changed header to GPL version 2 only sql/share/charsets/cp1256.xml: Changed header to GPL version 2 only sql/share/charsets/cp1257.xml: Changed header to GPL version 2 only sql/share/charsets/cp850.xml: Changed header to GPL version 2 only sql/share/charsets/cp852.xml: Changed header to GPL version 2 only sql/share/charsets/cp866.xml: Changed header to GPL version 2 only sql/share/charsets/dec8.xml: Changed header to GPL version 2 only sql/share/charsets/geostd8.xml: Changed header to GPL version 2 only sql/share/charsets/greek.xml: Changed header to GPL version 2 only sql/share/charsets/hebrew.xml: Changed header to GPL version 2 only sql/share/charsets/hp8.xml: Changed header to GPL version 2 only sql/share/charsets/keybcs2.xml: Changed header to GPL version 2 only sql/share/charsets/koi8r.xml: Changed header to GPL version 2 only sql/share/charsets/koi8u.xml: Changed header to GPL version 2 only sql/share/charsets/latin1.xml: Changed header to GPL version 2 only sql/share/charsets/latin2.xml: Changed header to GPL version 2 only sql/share/charsets/latin5.xml: Changed header to GPL version 2 only sql/share/charsets/latin7.xml: Changed header to GPL version 2 only sql/share/charsets/macce.xml: Changed header to GPL version 2 only sql/share/charsets/macroman.xml: Changed header to GPL version 2 only sql/share/charsets/swe7.xml: Changed header to GPL version 2 only sql/sql_view.cc: Changed header to GPL version 2 only sql/sql_view.h: Changed header to GPL version 2 only sql/sql_yacc.yy: Changed header to GPL version 2 only sql/stacktrace.c: Changed header to GPL version 2 only sql/stacktrace.h: Changed header to GPL version 2 only sql/strfunc.cc: Changed header to GPL version 2 only sql/structs.h: Changed header to GPL version 2 only sql/table.cc: Changed header to GPL version 2 only sql/table.h: Changed header to GPL version 2 only sql/thr_malloc.cc: Changed header to GPL version 2 only sql/time.cc: Changed header to GPL version 2 only sql/tzfile.h: Changed header to GPL version 2 only sql/tztime.cc: Changed header to GPL version 2 only sql/tztime.h: Changed header to GPL version 2 only sql/udf_example.c: Changed header to GPL version 2 only sql/uniques.cc: Changed header to GPL version 2 only sql/unireg.cc: Changed header to GPL version 2 only sql/unireg.h: Changed header to GPL version 2 only sql-bench/server-cfg.sh: Changed header to GPL version 2 only sql-bench/test-ATIS.sh: Changed header to GPL version 2 only sql-bench/test-alter-table.sh: Changed header to GPL version 2 only sql-bench/test-big-tables.sh: Changed header to GPL version 2 only sql-bench/test-connect.sh: Changed header to GPL version 2 only sql-bench/test-create.sh: Changed header to GPL version 2 only sql-bench/test-insert.sh: Changed header to GPL version 2 only sql-bench/test-select.sh: Changed header to GPL version 2 only sql-bench/test-transactions.sh: Changed header to GPL version 2 only sql-bench/test-wisconsin.sh: Changed header to GPL version 2 only sql-common/Makefile.am: Changed header to GPL version 2 only sql-common/client.c: Changed header to GPL version 2 only sql-common/my_time.c: Changed header to GPL version 2 only sql-common/my_user.c: Changed header to GPL version 2 only sql-common/pack.c: Changed header to GPL version 2 only strings/Makefile.am: Changed header to GPL version 2 only strings/bchange.c: Changed header to GPL version 2 only strings/bcmp.c: Changed header to GPL version 2 only strings/bcopy-duff.c: Changed header to GPL version 2 only strings/bfill.c: Changed header to GPL version 2 only strings/bmove.c: Changed header to GPL version 2 only strings/bmove512.c: Changed header to GPL version 2 only strings/bmove_upp-sparc.s: Changed header to GPL version 2 only strings/bmove_upp.c: Changed header to GPL version 2 only strings/bzero.c: Changed header to GPL version 2 only strings/conf_to_src.c: Changed header to GPL version 2 only strings/ctype-big5.c: Changed header to GPL version 2 only strings/ctype-bin.c: Changed header to GPL version 2 only strings/ctype-cp932.c: Changed header to GPL version 2 only strings/ctype-czech.c: Changed header to GPL version 2 only strings/ctype-euc_kr.c: Changed header to GPL version 2 only strings/ctype-eucjpms.c: Changed header to GPL version 2 only strings/ctype-gb2312.c: Changed header to GPL version 2 only strings/ctype-gbk.c: Changed header to GPL version 2 only strings/ctype-latin1.c: Changed header to GPL version 2 only strings/ctype-mb.c: Changed header to GPL version 2 only strings/ctype-simple.c: Changed header to GPL version 2 only strings/ctype-sjis.c: Changed header to GPL version 2 only strings/ctype-tis620.c: Changed header to GPL version 2 only strings/ctype-uca.c: Changed header to GPL version 2 only strings/ctype-ucs2.c: Changed header to GPL version 2 only strings/ctype-ujis.c: Changed header to GPL version 2 only strings/ctype-utf8.c: Changed header to GPL version 2 only strings/ctype-win1250ch.c: Changed header to GPL version 2 only strings/ctype.c: Changed header to GPL version 2 only strings/decimal.c: Changed header to GPL version 2 only strings/do_ctype.c: Changed header to GPL version 2 only strings/int2str.c: Changed header to GPL version 2 only strings/is_prefix.c: Changed header to GPL version 2 only strings/llstr.c: Changed header to GPL version 2 only strings/longlong2str-x86.s: Changed header to GPL version 2 only strings/longlong2str.c: Changed header to GPL version 2 only strings/longlong2str_asm.c: Changed header to GPL version 2 only strings/macros.asm: Changed header to GPL version 2 only strings/memcmp.c: Changed header to GPL version 2 only strings/memcpy.c: Changed header to GPL version 2 only strings/memset.c: Changed header to GPL version 2 only strings/my_strtoll10-x86.s: Changed header to GPL version 2 only strings/my_strtoll10.c: Changed header to GPL version 2 only strings/my_vsnprintf.c: Changed header to GPL version 2 only strings/ptr_cmp.asm: Changed header to GPL version 2 only strings/r_strinstr.c: Changed header to GPL version 2 only strings/str2int.c: Changed header to GPL version 2 only strings/str_alloc.c: Changed header to GPL version 2 only strings/str_test.c: Changed header to GPL version 2 only strings/strappend-sparc.s: Changed header to GPL version 2 only strings/strappend.c: Changed header to GPL version 2 only strings/strcat.c: Changed header to GPL version 2 only strings/strcend.c: Changed header to GPL version 2 only strings/strchr.c: Changed header to GPL version 2 only strings/strcmp.c: Changed header to GPL version 2 only strings/strcont.c: Changed header to GPL version 2 only strings/strend-sparc.s: Changed header to GPL version 2 only strings/strend.c: Changed header to GPL version 2 only strings/strfill.c: Changed header to GPL version 2 only strings/strings-not-used.h: Changed header to GPL version 2 only strings/strings-x86.s: Changed header to GPL version 2 only strings/strings.asm: Changed header to GPL version 2 only strings/strinstr-sparc.s: Changed header to GPL version 2 only strings/strinstr.c: Changed header to GPL version 2 only strings/strlen.c: Changed header to GPL version 2 only strings/strmake-sparc.s: Changed header to GPL version 2 only strings/strmake.c: Changed header to GPL version 2 only strings/strmov-sparc.s: Changed header to GPL version 2 only strings/strmov.c: Changed header to GPL version 2 only strings/strnlen.c: Changed header to GPL version 2 only strings/strnmov-sparc.s: Changed header to GPL version 2 only strings/strnmov.c: Changed header to GPL version 2 only strings/strrchr.c: Changed header to GPL version 2 only strings/strstr-sparc.s: Changed header to GPL version 2 only strings/strstr.c: Changed header to GPL version 2 only strings/strto.c: Changed header to GPL version 2 only strings/strtol.c: Changed header to GPL version 2 only strings/strtoll.c: Changed header to GPL version 2 only strings/strtoul.c: Changed header to GPL version 2 only strings/strtoull.c: Changed header to GPL version 2 only strings/strxmov-sparc.s: Changed header to GPL version 2 only strings/strxmov.asm: Changed header to GPL version 2 only strings/strxmov.c: Changed header to GPL version 2 only strings/strxnmov.c: Changed header to GPL version 2 only strings/t_ctype.h: Changed header to GPL version 2 only strings/udiv.c: Changed header to GPL version 2 only strings/xml.c: Changed header to GPL version 2 only support-files/MacOSX/Makefile.am: Changed header to GPL version 2 only support-files/Makefile.am: Changed header to GPL version 2 only support-files/MySQL-shared-compat.spec.sh: Changed header to GPL version 2 only tests/Makefile.am: Changed header to GPL version 2 only tests/connect_test.c: Changed header to GPL version 2 only tests/deadlock_test.c: Changed header to GPL version 2 only tests/insert_test.c: Changed header to GPL version 2 only tests/list_test.c: Changed header to GPL version 2 only tests/mysql_client_test.c: Changed header to GPL version 2 only tests/select_test.c: Changed header to GPL version 2 only tests/showdb_test.c: Changed header to GPL version 2 only tests/ssl_test.c: Changed header to GPL version 2 only tests/thread_test.c: Changed header to GPL version 2 only tools/Makefile.am: Changed header to GPL version 2 only tools/mysqlmanager.c: Changed header to GPL version 2 only vio/Makefile.am: Changed header to GPL version 2 only vio/test-ssl.c: Changed header to GPL version 2 only vio/test-sslclient.c: Changed header to GPL version 2 only vio/test-sslserver.c: Changed header to GPL version 2 only vio/vio.c: Changed header to GPL version 2 only vio/vio_priv.h: Changed header to GPL version 2 only vio/viosocket.c: Changed header to GPL version 2 only vio/viossl.c: Changed header to GPL version 2 only vio/viosslfactories.c: Changed header to GPL version 2 only vio/viotest-ssl.c: Changed header to GPL version 2 only win/Makefile.am: Changed header to GPL version 2 only zlib/Makefile.am: Changed header to GPL version 2 only
2006-12-23 20:17:15 +01:00
the Free Software Foundation; version 2 of the License.
simple subselects ported to new select_lex structures include/mysqld_error.h: simple subselects libmysqld/Makefile.am: simple subselects sql/Makefile.am: simple subselects sql/item.h: simple subselects sql/item_strfunc.h: simple subselects sql/share/czech/errmsg.txt: simple subselects sql/share/danish/errmsg.txt: simple subselects sql/share/dutch/errmsg.txt: simple subselects sql/share/english/errmsg.txt: simple subselects sql/share/estonian/errmsg.txt: simple subselects sql/share/french/errmsg.txt: simple subselects sql/share/german/errmsg.txt: simple subselects sql/share/greek/errmsg.txt: simple subselects sql/share/hungarian/errmsg.txt: simple subselects sql/share/italian/errmsg.txt: simple subselects sql/share/japanese/errmsg.txt: simple subselects sql/share/korean/errmsg.txt: simple subselects sql/share/norwegian-ny/errmsg.txt: simple subselects sql/share/norwegian/errmsg.txt: simple subselects sql/share/polish/errmsg.txt: simple subselects sql/share/portuguese/errmsg.txt: simple subselects sql/share/romanian/errmsg.txt: simple subselects sql/share/russian/errmsg.txt: simple subselects sql/share/slovak/errmsg.txt: simple subselects sql/share/spanish/errmsg.txt: simple subselects sql/share/swedish/errmsg.txt: simple subselects sql/share/ukrainian/errmsg.txt: simple subselects sql/sql_class.cc: simple subselects sql/sql_class.h: simple subselects sql/sql_lex.cc: simple subselects sql/sql_select.cc: simple subselects sql/sql_select.h: simple subselects sql/sql_union.cc: simple subselects sql/sql_yacc.yy: simple subselects
2002-05-12 22:46:42 +02:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
2007-10-11 19:29:09 +02:00
/**
@file
@brief
subselect Item
simple subselects ported to new select_lex structures include/mysqld_error.h: simple subselects libmysqld/Makefile.am: simple subselects sql/Makefile.am: simple subselects sql/item.h: simple subselects sql/item_strfunc.h: simple subselects sql/share/czech/errmsg.txt: simple subselects sql/share/danish/errmsg.txt: simple subselects sql/share/dutch/errmsg.txt: simple subselects sql/share/english/errmsg.txt: simple subselects sql/share/estonian/errmsg.txt: simple subselects sql/share/french/errmsg.txt: simple subselects sql/share/german/errmsg.txt: simple subselects sql/share/greek/errmsg.txt: simple subselects sql/share/hungarian/errmsg.txt: simple subselects sql/share/italian/errmsg.txt: simple subselects sql/share/japanese/errmsg.txt: simple subselects sql/share/korean/errmsg.txt: simple subselects sql/share/norwegian-ny/errmsg.txt: simple subselects sql/share/norwegian/errmsg.txt: simple subselects sql/share/polish/errmsg.txt: simple subselects sql/share/portuguese/errmsg.txt: simple subselects sql/share/romanian/errmsg.txt: simple subselects sql/share/russian/errmsg.txt: simple subselects sql/share/slovak/errmsg.txt: simple subselects sql/share/spanish/errmsg.txt: simple subselects sql/share/swedish/errmsg.txt: simple subselects sql/share/ukrainian/errmsg.txt: simple subselects sql/sql_class.cc: simple subselects sql/sql_class.h: simple subselects sql/sql_lex.cc: simple subselects sql/sql_select.cc: simple subselects sql/sql_select.h: simple subselects sql/sql_union.cc: simple subselects sql/sql_yacc.yy: simple subselects
2002-05-12 22:46:42 +02:00
2007-10-11 19:29:09 +02:00
@todo
- add function from mysql_select that use JOIN* as parameter to JOIN
methods (sql_select.h/sql_select.cc)
simple subselects ported to new select_lex structures include/mysqld_error.h: simple subselects libmysqld/Makefile.am: simple subselects sql/Makefile.am: simple subselects sql/item.h: simple subselects sql/item_strfunc.h: simple subselects sql/share/czech/errmsg.txt: simple subselects sql/share/danish/errmsg.txt: simple subselects sql/share/dutch/errmsg.txt: simple subselects sql/share/english/errmsg.txt: simple subselects sql/share/estonian/errmsg.txt: simple subselects sql/share/french/errmsg.txt: simple subselects sql/share/german/errmsg.txt: simple subselects sql/share/greek/errmsg.txt: simple subselects sql/share/hungarian/errmsg.txt: simple subselects sql/share/italian/errmsg.txt: simple subselects sql/share/japanese/errmsg.txt: simple subselects sql/share/korean/errmsg.txt: simple subselects sql/share/norwegian-ny/errmsg.txt: simple subselects sql/share/norwegian/errmsg.txt: simple subselects sql/share/polish/errmsg.txt: simple subselects sql/share/portuguese/errmsg.txt: simple subselects sql/share/romanian/errmsg.txt: simple subselects sql/share/russian/errmsg.txt: simple subselects sql/share/slovak/errmsg.txt: simple subselects sql/share/spanish/errmsg.txt: simple subselects sql/share/swedish/errmsg.txt: simple subselects sql/share/ukrainian/errmsg.txt: simple subselects sql/sql_class.cc: simple subselects sql/sql_class.h: simple subselects sql/sql_lex.cc: simple subselects sql/sql_select.cc: simple subselects sql/sql_select.h: simple subselects sql/sql_union.cc: simple subselects sql/sql_yacc.yy: simple subselects
2002-05-12 22:46:42 +02:00
*/
Add ifdefs to control when "#pragma implementation" should be used Added some more ifdefs for "#pragma interface" client/sql_string.cc: USE_PRAGMA_IMPLEMENTATION client/sql_string.h: USE_PRAGMA_INTERFACE include/my_global.h: Use pragma implementation for gcc pre version 3 mysys/raid.cc: USE_PRAGMA_IMPLEMENTATION sql/field.cc: USE_PRAGMA_IMPLEMENTATION sql/ha_berkeley.cc: USE_PRAGMA_IMPLEMENTATION sql/ha_blackhole.cc: USE_PRAGMA_IMPLEMENTATION sql/ha_heap.cc: USE_PRAGMA_IMPLEMENTATION sql/ha_innodb.cc: USE_PRAGMA_IMPLEMENTATION sql/ha_isam.cc: USE_PRAGMA_IMPLEMENTATION sql/ha_isammrg.cc: USE_PRAGMA_IMPLEMENTATION sql/ha_myisam.cc: USE_PRAGMA_IMPLEMENTATION sql/ha_myisammrg.cc: USE_PRAGMA_IMPLEMENTATION sql/ha_ndbcluster.cc: USE_PRAGMA_IMPLEMENTATION sql/handler.cc: USE_PRAGMA_IMPLEMENTATION sql/hash_filo.cc: USE_PRAGMA_IMPLEMENTATION sql/item.cc: USE_PRAGMA_IMPLEMENTATION sql/item_cmpfunc.cc: USE_PRAGMA_IMPLEMENTATION sql/item_func.cc: USE_PRAGMA_IMPLEMENTATION sql/item_geofunc.cc: USE_PRAGMA_IMPLEMENTATION sql/item_strfunc.cc: USE_PRAGMA_IMPLEMENTATION sql/item_subselect.cc: USE_PRAGMA_IMPLEMENTATION sql/item_sum.cc: USE_PRAGMA_IMPLEMENTATION sql/item_timefunc.cc: USE_PRAGMA_IMPLEMENTATION sql/item_uniq.cc: USE_PRAGMA_IMPLEMENTATION sql/item_uniq.h: USE_PRAGMA_INTERFACE sql/log_event.cc: USE_PRAGMA_IMPLEMENTATION sql/log_event.h: USE_PRAGMA_INTERFACE sql/opt_range.cc: USE_PRAGMA_IMPLEMENTATION sql/procedure.cc: USE_PRAGMA_IMPLEMENTATION sql/protocol.cc: USE_PRAGMA_IMPLEMENTATION sql/protocol_cursor.cc: USE_PRAGMA_IMPLEMENTATION sql/set_var.cc: USE_PRAGMA_IMPLEMENTATION sql/sql_analyse.cc: USE_PRAGMA_IMPLEMENTATION sql/sql_analyse.h: USE_PRAGMA_INTERFACE sql/sql_class.cc: USE_PRAGMA_IMPLEMENTATION sql/sql_crypt.cc: USE_PRAGMA_IMPLEMENTATION sql/sql_crypt.h: USE_PRAGMA_IMPLEMENTATION sql/sql_list.cc: USE_PRAGMA_IMPLEMENTATION sql/sql_map.cc: USE_PRAGMA_IMPLEMENTATION sql/sql_map.h: USE_PRAGMA_INTERFACE sql/sql_olap.cc: USE_PRAGMA_IMPLEMENTATION sql/sql_select.cc: USE_PRAGMA_IMPLEMENTATION sql/sql_string.cc: USE_PRAGMA_IMPLEMENTATION sql/sql_udf.cc: USE_PRAGMA_IMPLEMENTATION sql/tztime.cc: USE_PRAGMA_IMPLEMENTATION
2005-05-26 12:09:14 +02:00
#ifdef USE_PRAGMA_IMPLEMENTATION
simple subselects ported to new select_lex structures include/mysqld_error.h: simple subselects libmysqld/Makefile.am: simple subselects sql/Makefile.am: simple subselects sql/item.h: simple subselects sql/item_strfunc.h: simple subselects sql/share/czech/errmsg.txt: simple subselects sql/share/danish/errmsg.txt: simple subselects sql/share/dutch/errmsg.txt: simple subselects sql/share/english/errmsg.txt: simple subselects sql/share/estonian/errmsg.txt: simple subselects sql/share/french/errmsg.txt: simple subselects sql/share/german/errmsg.txt: simple subselects sql/share/greek/errmsg.txt: simple subselects sql/share/hungarian/errmsg.txt: simple subselects sql/share/italian/errmsg.txt: simple subselects sql/share/japanese/errmsg.txt: simple subselects sql/share/korean/errmsg.txt: simple subselects sql/share/norwegian-ny/errmsg.txt: simple subselects sql/share/norwegian/errmsg.txt: simple subselects sql/share/polish/errmsg.txt: simple subselects sql/share/portuguese/errmsg.txt: simple subselects sql/share/romanian/errmsg.txt: simple subselects sql/share/russian/errmsg.txt: simple subselects sql/share/slovak/errmsg.txt: simple subselects sql/share/spanish/errmsg.txt: simple subselects sql/share/swedish/errmsg.txt: simple subselects sql/share/ukrainian/errmsg.txt: simple subselects sql/sql_class.cc: simple subselects sql/sql_class.h: simple subselects sql/sql_lex.cc: simple subselects sql/sql_select.cc: simple subselects sql/sql_select.h: simple subselects sql/sql_union.cc: simple subselects sql/sql_yacc.yy: simple subselects
2002-05-12 22:46:42 +02:00
#pragma implementation // gcc: Class implementation
#endif
#include "mysql_priv.h"
#include "sql_select.h"
2011-05-25 17:31:13 +02:00
double get_post_group_estimate(JOIN* join, double join_op_rows);
Item_subselect::Item_subselect():
2011-05-29 10:58:44 +02:00
Item_result_field(), value_assigned(0), own_engine(0), thd(0), old_engine(0),
used_tables_cache(0), have_to_be_excluded(0), const_item_cache(1),
inside_first_fix_fields(0), done_first_fix_fields(FALSE),
expr_cache(0), forced_const(FALSE), substitution(0), engine(0), eliminated(FALSE),
engine_changed(0), changed(0), is_correlated(FALSE)
simple subselects ported to new select_lex structures include/mysqld_error.h: simple subselects libmysqld/Makefile.am: simple subselects sql/Makefile.am: simple subselects sql/item.h: simple subselects sql/item_strfunc.h: simple subselects sql/share/czech/errmsg.txt: simple subselects sql/share/danish/errmsg.txt: simple subselects sql/share/dutch/errmsg.txt: simple subselects sql/share/english/errmsg.txt: simple subselects sql/share/estonian/errmsg.txt: simple subselects sql/share/french/errmsg.txt: simple subselects sql/share/german/errmsg.txt: simple subselects sql/share/greek/errmsg.txt: simple subselects sql/share/hungarian/errmsg.txt: simple subselects sql/share/italian/errmsg.txt: simple subselects sql/share/japanese/errmsg.txt: simple subselects sql/share/korean/errmsg.txt: simple subselects sql/share/norwegian-ny/errmsg.txt: simple subselects sql/share/norwegian/errmsg.txt: simple subselects sql/share/polish/errmsg.txt: simple subselects sql/share/portuguese/errmsg.txt: simple subselects sql/share/romanian/errmsg.txt: simple subselects sql/share/russian/errmsg.txt: simple subselects sql/share/slovak/errmsg.txt: simple subselects sql/share/spanish/errmsg.txt: simple subselects sql/share/swedish/errmsg.txt: simple subselects sql/share/ukrainian/errmsg.txt: simple subselects sql/sql_class.cc: simple subselects sql/sql_class.h: simple subselects sql/sql_lex.cc: simple subselects sql/sql_select.cc: simple subselects sql/sql_select.h: simple subselects sql/sql_union.cc: simple subselects sql/sql_yacc.yy: simple subselects
2002-05-12 22:46:42 +02:00
{
DBUG_ENTER("Item_subselect::Item_subselect");
DBUG_PRINT("enter", ("this: 0x%lx", (ulong) this));
#ifndef DBUG_OFF
exec_counter= 0;
#endif
Fixed bug#19077: A nested materialized derived table is used before being populated. The convert_constant_item() function converts constant items to ints on prepare phase to optimize execution speed. In this case it tries to evaluate subselect which contains a derived table and is contained in a derived table. All derived tables are filled only after all derived tables are prepared. So evaluation of subselect with derived table at the prepare phase will return a wrong result. A new flag with_subselect is added to the Item class. It indicates that expression which this item represents is a subselect or contains a subselect. It is set to 0 by default. It is set to 1 in the Item_subselect constructor for subselects. For Item_func and Item_cond derived classes it is set after fixing any argument in Item_func::fix_fields() and Item_cond::fix_fields accordingly. The convert_constant_item() function now doesn't convert a constant item if the with_subselect flag set in it. mysql-test/t/view.test: Added test case for bug#19077: A nested materialized derived table is used before being populated. mysql-test/t/subselect.test: Added test case for bug#19077: A nested materialized derived table is used before being populated. mysql-test/r/view.result: Added test case for bug#19077: A nested materialized derived table is used before being populated. mysql-test/r/subselect.result: Added test case for bug#19077: A nested materialized derived table is used before being populated. sql/item_subselect.cc: Fixed bug#19077: A nested materialized derived table is used before being populated. The Item_subselect class constructor sets new with_subselect flag to 1. sql/item_func.cc: Fixed bug#19077: A nested materialized derived table is used before being populated. The Item_func::fix_fields() sets new with_subselect flag from with_subselect flags of its arguments. sql/item_cmpfunc.cc: Fixed bug#19077: A nested materialized derived table is used before being populated. The convert_constant_item() function now doesn't convert a constant item with the with_subselect flag set. The Item_cond::fix_fields() sets new with_subselect flag from with_subselect flags of its arguments. sql/item.cc: Fixed bug#19077: A nested materialized derived table is used before being populated. Set new with_subselect flag to default value - 0 in the Item constructor. sql/item.h: Fixed bug#19077: A nested materialized derived table is used before being populated. A new flag with_subselect is added to the Item class. It indicates that expression which this item represents is a subselect or contains a subselect. It is set to 0 by default.
2006-05-17 22:55:28 +02:00
with_subselect= 1;
reset();
/*
Item value is NULL if select_result_interceptor didn't change this value
(i.e. some rows will be found returned)
*/
null_value= TRUE;
DBUG_VOID_RETURN;
}
void Item_subselect::init(st_select_lex *select_lex,
select_result_interceptor *result)
{
/*
Please see Item_singlerow_subselect::invalidate_and_restore_select_lex(),
which depends on alterations to the parse tree implemented here.
*/
DBUG_ENTER("Item_subselect::init");
DBUG_PRINT("enter", ("select_lex: 0x%lx this: 0x%lx",
(ulong) select_lex, (ulong) this));
unit= select_lex->master_unit();
thd= unit->thd;
if (unit->item)
{
/*
Item can be changed in JOIN::prepare while engine in JOIN::optimize
=> we do not copy old_engine here
*/
engine= unit->item->engine;
own_engine= FALSE;
parsing_place= unit->item->parsing_place;
thd->change_item_tree((Item**)&unit->item, this);
engine->change_result(this, result, TRUE);
}
else
{
SELECT_LEX *outer_select= unit->outer_select();
/*
do not take into account expression inside aggregate functions because
they can access original table fields
*/
parsing_place= (outer_select->in_sum_expr ?
NO_MATTER :
outer_select->parsing_place);
if (unit->is_union())
engine= new subselect_union_engine(thd, unit, result, this);
else
engine= new subselect_single_select_engine(thd, select_lex, result, this);
}
{
SELECT_LEX *upper= unit->outer_select();
if (upper->parsing_place == IN_HAVING)
upper->subquery_in_having= 1;
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
/* The subquery is an expression cache candidate */
upper->expr_cache_may_be_used[upper->parsing_place]= TRUE;
}
DBUG_PRINT("info", ("engine: 0x%lx", (ulong)engine));
simple subselects ported to new select_lex structures include/mysqld_error.h: simple subselects libmysqld/Makefile.am: simple subselects sql/Makefile.am: simple subselects sql/item.h: simple subselects sql/item_strfunc.h: simple subselects sql/share/czech/errmsg.txt: simple subselects sql/share/danish/errmsg.txt: simple subselects sql/share/dutch/errmsg.txt: simple subselects sql/share/english/errmsg.txt: simple subselects sql/share/estonian/errmsg.txt: simple subselects sql/share/french/errmsg.txt: simple subselects sql/share/german/errmsg.txt: simple subselects sql/share/greek/errmsg.txt: simple subselects sql/share/hungarian/errmsg.txt: simple subselects sql/share/italian/errmsg.txt: simple subselects sql/share/japanese/errmsg.txt: simple subselects sql/share/korean/errmsg.txt: simple subselects sql/share/norwegian-ny/errmsg.txt: simple subselects sql/share/norwegian/errmsg.txt: simple subselects sql/share/polish/errmsg.txt: simple subselects sql/share/portuguese/errmsg.txt: simple subselects sql/share/romanian/errmsg.txt: simple subselects sql/share/russian/errmsg.txt: simple subselects sql/share/slovak/errmsg.txt: simple subselects sql/share/spanish/errmsg.txt: simple subselects sql/share/swedish/errmsg.txt: simple subselects sql/share/ukrainian/errmsg.txt: simple subselects sql/sql_class.cc: simple subselects sql/sql_class.h: simple subselects sql/sql_lex.cc: simple subselects sql/sql_select.cc: simple subselects sql/sql_select.h: simple subselects sql/sql_union.cc: simple subselects sql/sql_yacc.yy: simple subselects
2002-05-12 22:46:42 +02:00
DBUG_VOID_RETURN;
}
st_select_lex *
Item_subselect::get_select_lex()
{
return unit->first_select();
}
void Item_subselect::cleanup()
{
DBUG_ENTER("Item_subselect::cleanup");
Item_result_field::cleanup();
if (old_engine)
{
if (engine)
engine->cleanup();
engine= old_engine;
old_engine= 0;
}
if (engine)
engine->cleanup();
reset();
value_assigned= 0;
Fixed LP BUG#615760: Check on double cache assignment added into the transformation methods. Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/compare.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/group_by.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect4.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_cache.result: Added test suite for LP BUG#615760 mysql-test/r/subselect_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_opts.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_semijoin.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/suite/pbxt/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/t/subselect_cache.test: Cache parameters print added in EXPLAIN EXTENDED output. sql/item.cc: Item::set_expr_cache result fixed according to its description. Cache parameters print added in EXPLAIN EXTENDED output. sql/item.h: Cache parameters print added in EXPLAIN EXTENDED output. sql/item_cmpfunc.cc: Check on double cache assignment added into the transformation methods. sql/item_cmpfunc.h: Check on double cache assignment added into the transformation methods. sql/item_subselect.cc: Check on double cache assignment added into the transformation methods. sql/item_subselect.h: Check on double cache assignment added into the transformation methods. sql/sql_expression_cache.cc: Cache parameters print added. sql/sql_expression_cache.h: Cache parameters print added. sql/sql_select.cc: Removed unused method (now it is impossible to make double transformation with the cache). sql/sql_select.h: Removed unused method.
2010-09-06 14:34:24 +02:00
expr_cache= 0;
forced_const= FALSE;
DBUG_PRINT("info", ("exec_counter: %d", exec_counter));
#ifndef DBUG_OFF
exec_counter= 0;
#endif
DBUG_VOID_RETURN;
}
void Item_singlerow_subselect::cleanup()
{
DBUG_ENTER("Item_singlerow_subselect::cleanup");
value= 0; row= 0;
Item_subselect::cleanup();
DBUG_VOID_RETURN;
}
void Item_in_subselect::cleanup()
{
DBUG_ENTER("Item_in_subselect::cleanup");
if (left_expr_cache)
{
left_expr_cache->delete_elements();
delete left_expr_cache;
left_expr_cache= NULL;
}
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
/*
TODO: This breaks the commented assert in add_strategy().
in_strategy&= ~SUBS_STRATEGY_CHOSEN;
*/
first_execution= TRUE;
pushed_cond_guards= NULL;
Item_subselect::cleanup();
DBUG_VOID_RETURN;
}
void Item_allany_subselect::cleanup()
{
/*
The MAX/MIN transformation through injection is reverted through the
change_item_tree() mechanism. Revert the select_lex object of the
query to its initial state.
*/
for (SELECT_LEX *sl= unit->first_select();
sl; sl= sl->next_select())
if (test_set_strategy(SUBS_MAXMIN_INJECTED))
sl->with_sum_func= false;
Item_in_subselect::cleanup();
}
Item_subselect::~Item_subselect()
{
DBUG_ENTER("Item_subselect::~Item_subselect");
DBUG_PRINT("enter", ("this: 0x%lx", (ulong) this));
if (own_engine)
delete engine;
else
engine->cleanup();
engine= NULL;
DBUG_VOID_RETURN;
}
bool
Item_subselect::select_transformer(JOIN *join)
{
DBUG_ENTER("Item_subselect::select_transformer");
DBUG_RETURN(false);
}
Name resolution context added (BUG#6443) include/my_bitmap.h: new bitmap operation mysql-test/r/view.result: added warnings Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysql-test/t/view.test: Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysys/my_bitmap.c: new bitmap operation sql/field.h: index of field in table added sql/item.cc: Name resolution context added table list removed from fix_fields() arguments sql/item.h: Name resolution context added table list removed from fix_fields() arguments sql/item_cmpfunc.cc: table list removed from fix_fields() arguments sql/item_cmpfunc.h: table list removed from fix_fields() arguments sql/item_func.cc: table list removed from fix_fields() arguments sql/item_func.h: table list removed from fix_fields() arguments sql/item_row.cc: table list removed from fix_fields() arguments sql/item_row.h: table list removed from fix_fields() arguments sql/item_strfunc.cc: fixed server crash on NULL argument sql/item_strfunc.h: table list removed from fix_fields() arguments sql/item_subselect.cc: table list removed from fix_fields() arguments sql/item_subselect.h: table list removed from fix_fields() arguments sql/item_sum.cc: table list removed from fix_fields() arguments sql/item_sum.h: table list removed from fix_fields() arguments sql/item_timefunc.cc: table list removed from fix_fields() arguments sql/item_timefunc.h: table list removed from fix_fields() arguments sql/item_uniq.h: table list removed from fix_fields() arguments sql/log_event.cc: Name resolution context added sql/log_event.h: Name resolution context added sql/mysql_priv.h: Name resolution context added sql/set_var.cc: table list removed from fix_fields() arguments sql/share/errmsg.txt: new error message sql/sp.cc: Name resolution context added sql/sp_head.cc: table list removed from fix_fields() arguments sql/sp_head.h: Name resolution context added sql/sql_base.cc: table list removed from fix_fields() arguments Name resolution context added sql/sql_class.cc: renamed variable sql/sql_delete.cc: Name resolution context added sql/sql_derived.cc: Name resolution context added sql/sql_do.cc: table list removed from fix_fields() arguments sql/sql_handler.cc: Name resolution context added sql/sql_help.cc: Name resolution context added sql/sql_insert.cc: Name resolution context added table list removed from fix_fields() arguments sql/sql_lex.cc: Name resolution context added sql/sql_lex.h: removed resolve mode (information stored into name resolution context) sql/sql_load.cc: table list removed from fix_fields() arguments sql/sql_olap.cc: Name resolution context added sql/sql_parse.cc: Name resolution context added sql/sql_prepare.cc: table list removed from fix_fields() arguments sql/sql_select.cc: table list removed from fix_fields() arguments sql/sql_show.cc: Name resolution context added sql/sql_trigger.cc: table list removed from fix_fields() arguments sql/sql_udf.h: table list removed from fix_fields() arguments sql/sql_union.cc: Name resolution context added sql/sql_update.cc: Name resolution context added sql/sql_view.cc: Name resolution context added sql/sql_view.h: table list removed from fix_fields() arguments sql/sql_yacc.yy: Name resolution context added sql/table.cc: Name resolution context added merged view processing moved sql/table.h: merged view processing moved
2005-07-01 06:05:42 +02:00
bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
simple subselects ported to new select_lex structures include/mysqld_error.h: simple subselects libmysqld/Makefile.am: simple subselects sql/Makefile.am: simple subselects sql/item.h: simple subselects sql/item_strfunc.h: simple subselects sql/share/czech/errmsg.txt: simple subselects sql/share/danish/errmsg.txt: simple subselects sql/share/dutch/errmsg.txt: simple subselects sql/share/english/errmsg.txt: simple subselects sql/share/estonian/errmsg.txt: simple subselects sql/share/french/errmsg.txt: simple subselects sql/share/german/errmsg.txt: simple subselects sql/share/greek/errmsg.txt: simple subselects sql/share/hungarian/errmsg.txt: simple subselects sql/share/italian/errmsg.txt: simple subselects sql/share/japanese/errmsg.txt: simple subselects sql/share/korean/errmsg.txt: simple subselects sql/share/norwegian-ny/errmsg.txt: simple subselects sql/share/norwegian/errmsg.txt: simple subselects sql/share/polish/errmsg.txt: simple subselects sql/share/portuguese/errmsg.txt: simple subselects sql/share/romanian/errmsg.txt: simple subselects sql/share/russian/errmsg.txt: simple subselects sql/share/slovak/errmsg.txt: simple subselects sql/share/spanish/errmsg.txt: simple subselects sql/share/swedish/errmsg.txt: simple subselects sql/share/ukrainian/errmsg.txt: simple subselects sql/sql_class.cc: simple subselects sql/sql_class.h: simple subselects sql/sql_lex.cc: simple subselects sql/sql_select.cc: simple subselects sql/sql_select.h: simple subselects sql/sql_union.cc: simple subselects sql/sql_yacc.yy: simple subselects
2002-05-12 22:46:42 +02:00
{
Merge with 4.1 (Includes merge of arena code in 4.1 and 5.0) BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged client/mysql.cc: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/client_settings.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/examples/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged myisam/sort.c: Auto merged mysql-test/r/connect.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/func_in.result: Auto merged mysql-test/r/func_like.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/having.result: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/join.result: Auto merged mysql-test/r/key.result: Auto merged mysql-test/r/lowercase_table.result: Auto merged mysql-test/r/ndb_autodiscover.result: Auto merged mysql-test/r/null.result: Auto merged mysql-test/r/olap.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/rename.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/null.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/rpl_charset.test: Auto merged mysql-test/t/rpl_heap.test: Auto merged mysql-test/t/rpl_relayrotate.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/variables.test: Auto merged netware/mysql_test_run.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged scripts/mysql_install_db.sh: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_create.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_sum.cc: Auto merged sql/protocol.cc: Auto merged sql/records.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_list.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_string.h: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged client/mysqlbinlog.cc: Merge with 4.1 configure.in: Merge with 4.1 include/mysqld_error.h: Add new error message (1) from 4.1 mysql-test/mysql-test-run.sh: Merge with 4.1 mysql-test/r/func_gconcat.result: Merge with 4.1 mysql-test/r/func_if.result: Merge with 4.1 mysql-test/r/grant.result: Merge with 4.1 mysql-test/r/join_outer.result: Merge with 4.1 mysql-test/r/rpl_charset.result: Merge with 4.1 (This has to be fixed before pushing) mysql-test/r/system_mysql_db.result: Merge with 4.1. Added collation to new privileges mysql-test/t/grant.test: Merge with 4.1 mysql-test/t/grant_cache.test: Merge with 4.1 mysql-test/t/show_check.test: Merge with 4.1 sql/Makefile.am: Merge with 4.1 sql/item.cc: Merge with 4.1 sql/item_cmpfunc.cc: Merge with 4.1 (arena code) sql/item_subselect.cc: Merge with 4.1 sql/item_subselect.h: Merge with 4.1 sql/item_sum.cc: Merge with 4.1 sql/item_sum.h: Merge with 4.1 sql/log.cc: Merge with 4.1 (Remove code that is not relevant for 5.0) sql/mysqld.cc: Merge with 4.1 sql/opt_range.cc: Merge with 4.1 sql/share/czech/errmsg.txt: Merge with 4.1 sql/share/danish/errmsg.txt: Merge with 4.1 sql/share/dutch/errmsg.txt: Merge with 4.1 sql/share/english/errmsg.txt: Merge with 4.1 sql/share/estonian/errmsg.txt: Merge with 4.1 sql/share/french/errmsg.txt: Merge with 4.1 sql/share/german/errmsg.txt: Merge with 4.1 sql/share/greek/errmsg.txt: Merge with 4.1 sql/share/hungarian/errmsg.txt: Merge with 4.1 sql/share/italian/errmsg.txt: Merge with 4.1 sql/share/japanese/errmsg.txt: Merge with 4.1 sql/share/korean/errmsg.txt: Merge with 4.1 sql/share/norwegian-ny/errmsg.txt: Merge with 4.1 sql/share/norwegian/errmsg.txt: Merge with 4.1 sql/share/polish/errmsg.txt: Merge with 4.1 sql/share/portuguese/errmsg.txt: Merge with 4.1 sql/share/romanian/errmsg.txt: Merge with 4.1 sql/share/russian/errmsg.txt: Merge with 4.1 sql/share/serbian/errmsg.txt: Merge with 4.1 sql/share/slovak/errmsg.txt: Merge with 4.1 sql/share/spanish/errmsg.txt: Merge with 4.1 sql/share/swedish/errmsg.txt: Merge with 4.1 sql/share/ukrainian/errmsg.txt: Merge with 4.1 sql/sql_base.cc: Merge with 4.1 sql/sql_class.cc: Merge with 4.1 Use arena code from 4.1 sql/sql_class.h: Merge with 4.1 Use arena code from 4.1 sql/sql_derived.cc: Merge with 4.1 sql/sql_lex.cc: Merge with 4.1 sql/sql_lex.h: Merge with 4.1 sql/sql_parse.cc: Merge with 4.1 sql/sql_prepare.cc: Merge with 4.1 sql/sql_select.cc: Merge with 4.1 sql/sql_table.cc: Merge with 4.1 sql/sql_union.cc: Merge with 4.1 sql/sql_yacc.yy: Merge with 4.1 sql/tztime.cc: Merge with 4.1 tests/client_test.c: Merge with 4.1
2004-09-06 14:14:10 +02:00
char const *save_where= thd_param->where;
Table definition cache, part 2 The table opening process now works the following way: - Create common TABLE_SHARE object - Read the .frm file and unpack it into the TABLE_SHARE object - Create a TABLE object based on the information in the TABLE_SHARE object and open a handler to the table object Other noteworthy changes: - In TABLE_SHARE the most common strings are now LEX_STRING's - Better error message when table is not found - Variable table_cache is now renamed 'table_open_cache' - New variable 'table_definition_cache' that is the number of table defintions that will be cached - strxnmov() calls are now fixed to avoid overflows - strxnmov() will now always add one end \0 to result - engine objects are now created with a TABLE_SHARE object instead of a TABLE object. - After creating a field object one must call field->init(table) before using it - For a busy system this change will give you: - Less memory usage for table object - Faster opening of tables (if it's has been in use or is in table definition cache) - Allow you to cache many table definitions objects - Faster drop of table mysql-test/mysql-test-run.sh: Fixed some problems with --gdb option Test both with socket and tcp/ip port that all old servers are killed mysql-test/r/flush_table.result: More tests with lock table with 2 threads + flush table mysql-test/r/information_schema.result: Removed old (now wrong) result mysql-test/r/innodb.result: Better error messages (thanks to TDC patch) mysql-test/r/merge.result: Extra flush table test mysql-test/r/ndb_bitfield.result: Better error messages (thanks to TDC patch) mysql-test/r/ndb_partition_error.result: Better error messages (thanks to TDC patch) mysql-test/r/query_cache.result: Remove tables left from old tests mysql-test/r/temp_table.result: Test truncate with temporary tables mysql-test/r/variables.result: Table_cache -> Table_open_cache mysql-test/t/flush_table.test: More tests with lock table with 2 threads + flush table mysql-test/t/merge.test: Extra flush table test mysql-test/t/multi_update.test: Added 'sleep' to make test predictable mysql-test/t/query_cache.test: Remove tables left from old tests mysql-test/t/temp_table.test: Test truncate with temporary tables mysql-test/t/variables.test: Table_cache -> Table_open_cache mysql-test/valgrind.supp: Remove warning that may happens becasue threads dies in different order mysys/hash.c: Fixed wrong DBUG_PRINT mysys/mf_dirname.c: More DBUG mysys/mf_pack.c: Better comment mysys/mf_tempdir.c: More DBUG Ensure that we call cleanup_dirname() on all temporary directory paths. If we don't do this, we will get a failure when comparing temporary table names as in some cases the temporary table name is run through convert_dirname()) mysys/my_alloc.c: Indentation fix sql/examples/ha_example.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_example.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_tina.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_tina.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/field.cc: Update for table definition cache: - Field creation now takes TABLE_SHARE instead of TABLE as argument (This is becasue field definitions are now cached in TABLE_SHARE) When a field is created, one now must call field->init(TABLE) before using it - Use s->db instead of s->table_cache_key - Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE - make_field() takes TABLE_SHARE as argument instead of TABLE - move_field() -> move_field_offset() sql/field.h: Update for table definition cache: - Field creation now takes TABLE_SHARE instead of TABLE as argument (This is becasue field definitions are now cached in TABLE_SHARE) When a field is created, one now must call field->init(TABLE) before using it - Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE - make_field() takes TABLE_SHARE as argument instead of TABLE - move_field() -> move_field_offset() sql/ha_archive.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_archive.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_berkeley.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Changed name of argument create() to not hide internal 'table' variable. table->s -> table_share sql/ha_berkeley.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_blackhole.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_blackhole.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_federated.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Fixed comments Remove index variable and replace with pointers (simple optimization) move_field() -> move_field_offset() Removed some strlen() calls sql/ha_federated.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_heap.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Simplify delete_table() and create() as the given file names are now without extension sql/ha_heap.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_innodb.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_innodb.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_myisam.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Remove not needed fn_format() Fixed for new table->s structure sql/ha_myisam.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_myisammrg.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Don't set 'is_view' for MERGE tables Use new interface to find_temporary_table() sql/ha_myisammrg.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers Added flag HA_NO_COPY_ON_ALTER sql/ha_ndbcluster.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Fixed wrong calls to strxnmov() Give error HA_ERR_TABLE_DEF_CHANGED if table definition has changed drop_table -> intern_drop_table() table->s -> table_share Move part_info to TABLE Fixed comments & DBUG print's New arguments to print_error() sql/ha_ndbcluster.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_partition.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers We can't set up or use part_info when creating handler as there is not yet any table object New ha_intialise() to work with TDC (Done by Mikael) sql/ha_partition.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers Got set_part_info() from Mikael sql/handler.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers ha_delete_table() now also takes database as an argument handler::ha_open() now takes TABLE as argument ha_open() now calls ha_allocate_read_write_set() Simplify ha_allocate_read_write_set() Remove ha_deallocate_read_write_set() Use table_share (Cached by table definition cache) sql/handler.h: New table flag: HA_NO_COPY_ON_ALTER (used by merge tables) Remove ha_deallocate_read_write_set() get_new_handler() now takes TABLE_SHARE as argument ha_delete_table() now gets database as argument sql/item.cc: table_name and db are now LEX_STRING objects When creating fields, we have now have to call field->init(table) move_field -> move_field_offset() sql/item.h: tmp_table_field_from_field_type() now takes an extra paramenter 'fixed_length' to allow one to force usage of CHAR instead of BLOB sql/item_cmpfunc.cc: Fixed call to tmp_table_field_from_field_type() sql/item_create.cc: Assert if new not handled cast type sql/item_func.cc: When creating fields, we have now have to call field->init(table) dummy_table used by 'sp' now needs a TABLE_SHARE object sql/item_subselect.cc: Trivial code cleanups sql/item_sum.cc: When creating fields, we have now have to call field->init(table) sql/item_timefunc.cc: Item_func_str_to_date::tmp_table_field() now replaced by call to tmp_table_field_from_field_type() (see item_timefunc.h) sql/item_timefunc.h: Simply tmp_table_field() sql/item_uniq.cc: When creating fields, we have now have to call field->init(table) sql/key.cc: Added 'KEY' argument to 'find_ref_key' to simplify code sql/lock.cc: More debugging Use create_table_def_key() to create key for table cache Allocate TABLE_SHARE properly when creating name lock Fix that locked_table_name doesn't test same table twice sql/mysql_priv.h: New functions for table definition cache New interfaces to a lot of functions. New faster interface to find_temporary_table() and close_temporary_table() sql/mysqld.cc: Added support for table definition cache of size 'table_def_size' Fixed som calls to strnmov() Changed name of 'table_cache' to 'table_open_cache' sql/opt_range.cc: Use new interfaces Fixed warnings from valgrind sql/parse_file.cc: Safer calls to strxnmov() Fixed typo sql/set_var.cc: Added variable 'table_definition_cache' Variable table_cache renamed to 'table_open_cache' sql/slave.cc: Use new interface sql/sp.cc: Proper use of TABLE_SHARE sql/sp_head.cc: Remove compiler warnings We have now to call field->init(table) sql/sp_head.h: Pointers to parsed strings are now const sql/sql_acl.cc: table_name is now a LEX_STRING sql/sql_base.cc: Main implementation of table definition cache (The #ifdef's are there for the future when table definition cache will replace open table cache) Now table definitions are cached indepndent of open tables, which will speed up things when a table is in use at once from several places Views are not yet cached; For the moment we only cache if a table is a view or not. Faster implementation of find_temorary_table() Replace 'wait_for_refresh()' with the more general function 'wait_for_condition()' Drop table is slightly faster as we can use the table definition cache to know the type of the table sql/sql_cache.cc: table_cache_key and table_name are now LEX_STRING 'sDBUG print fixes sql/sql_class.cc: table_cache_key is now a LEX_STRING safer strxnmov() sql/sql_class.h: Added number of open table shares (table definitions) sql/sql_db.cc: safer strxnmov() sql/sql_delete.cc: Use new interface to find_temporary_table() sql/sql_derived.cc: table_name is now a LEX_STRING sql/sql_handler.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's sql/sql_insert.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's sql/sql_lex.cc: Make parsed string a const (to quickly find out if anything is trying to change the query string) sql/sql_lex.h: Make parsed string a const (to quickly find out if anything is trying to change the query string) sql/sql_load.cc: Safer strxnmov() sql/sql_parse.cc: Better error if wrong DB name sql/sql_partition.cc: part_info moved to TABLE from TABLE_SHARE Indentation changes sql/sql_select.cc: Indentation fixes Call field->init(TABLE) for new created fields Update create_tmp_table() to use TABLE_SHARE properly sql/sql_select.h: Call field->init(TABLE) for new created fields sql/sql_show.cc: table_name is now a LEX_STRING part_info moved to TABLE sql/sql_table.cc: Use table definition cache to speed up delete of tables Fixed calls to functions with new interfaces Don't use 'share_not_to_be_used' Instead of doing openfrm() when doing repair, we now have to call get_table_share() followed by open_table_from_share(). Replace some fn_format() with faster unpack_filename(). Safer strxnmov() part_info is now in TABLE Added Mikaels patch for partition and ALTER TABLE Instead of using 'TABLE_SHARE->is_view' use 'table_flags() & HA_NO_COPY_ON_ALTER sql/sql_test.cc: table_name and table_cache_key are now LEX_STRING's sql/sql_trigger.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's safer strxnmov() Removed compiler warnings sql/sql_update.cc: Call field->init(TABLE) after field is created sql/sql_view.cc: safer strxnmov() Create common TABLE_SHARE object for views to allow us to cache if table is a view sql/structs.h: Added SHOW_TABLE_DEFINITIONS sql/table.cc: Creation and destruct of TABLE_SHARE objects that are common for many TABLE objects The table opening process now works the following way: - Create common TABLE_SHARE object - Read the .frm file and unpack it into the TABLE_SHARE object - Create a TABLE object based on the information in the TABLE_SHARE object and open a handler to the table object open_table_def() is written in such a way that it should be trival to add parsing of the .frm files in new formats sql/table.h: TABLE objects for the same database table now share a common TABLE_SHARE object In TABLE_SHARE the most common strings are now LEX_STRING's sql/unireg.cc: Changed arguments to rea_create_table() to have same order as other functions Call field->init(table) for new created fields sql/unireg.h: Added OPEN_VIEW strings/strxnmov.c: Change strxnmov() to always add end \0 This makes usage of strxnmov() safer as most of MySQL code assumes that strxnmov() will create a null terminated string
2005-11-23 21:45:02 +01:00
uint8 uncacheable;
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
bool res;
Merge with 4.1 (Includes merge of arena code in 4.1 and 5.0) BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged client/mysql.cc: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/client_settings.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/examples/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged myisam/sort.c: Auto merged mysql-test/r/connect.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/func_in.result: Auto merged mysql-test/r/func_like.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/having.result: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/join.result: Auto merged mysql-test/r/key.result: Auto merged mysql-test/r/lowercase_table.result: Auto merged mysql-test/r/ndb_autodiscover.result: Auto merged mysql-test/r/null.result: Auto merged mysql-test/r/olap.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/rename.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/null.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/rpl_charset.test: Auto merged mysql-test/t/rpl_heap.test: Auto merged mysql-test/t/rpl_relayrotate.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/variables.test: Auto merged netware/mysql_test_run.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged scripts/mysql_install_db.sh: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_create.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_sum.cc: Auto merged sql/protocol.cc: Auto merged sql/records.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_list.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_string.h: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged client/mysqlbinlog.cc: Merge with 4.1 configure.in: Merge with 4.1 include/mysqld_error.h: Add new error message (1) from 4.1 mysql-test/mysql-test-run.sh: Merge with 4.1 mysql-test/r/func_gconcat.result: Merge with 4.1 mysql-test/r/func_if.result: Merge with 4.1 mysql-test/r/grant.result: Merge with 4.1 mysql-test/r/join_outer.result: Merge with 4.1 mysql-test/r/rpl_charset.result: Merge with 4.1 (This has to be fixed before pushing) mysql-test/r/system_mysql_db.result: Merge with 4.1. Added collation to new privileges mysql-test/t/grant.test: Merge with 4.1 mysql-test/t/grant_cache.test: Merge with 4.1 mysql-test/t/show_check.test: Merge with 4.1 sql/Makefile.am: Merge with 4.1 sql/item.cc: Merge with 4.1 sql/item_cmpfunc.cc: Merge with 4.1 (arena code) sql/item_subselect.cc: Merge with 4.1 sql/item_subselect.h: Merge with 4.1 sql/item_sum.cc: Merge with 4.1 sql/item_sum.h: Merge with 4.1 sql/log.cc: Merge with 4.1 (Remove code that is not relevant for 5.0) sql/mysqld.cc: Merge with 4.1 sql/opt_range.cc: Merge with 4.1 sql/share/czech/errmsg.txt: Merge with 4.1 sql/share/danish/errmsg.txt: Merge with 4.1 sql/share/dutch/errmsg.txt: Merge with 4.1 sql/share/english/errmsg.txt: Merge with 4.1 sql/share/estonian/errmsg.txt: Merge with 4.1 sql/share/french/errmsg.txt: Merge with 4.1 sql/share/german/errmsg.txt: Merge with 4.1 sql/share/greek/errmsg.txt: Merge with 4.1 sql/share/hungarian/errmsg.txt: Merge with 4.1 sql/share/italian/errmsg.txt: Merge with 4.1 sql/share/japanese/errmsg.txt: Merge with 4.1 sql/share/korean/errmsg.txt: Merge with 4.1 sql/share/norwegian-ny/errmsg.txt: Merge with 4.1 sql/share/norwegian/errmsg.txt: Merge with 4.1 sql/share/polish/errmsg.txt: Merge with 4.1 sql/share/portuguese/errmsg.txt: Merge with 4.1 sql/share/romanian/errmsg.txt: Merge with 4.1 sql/share/russian/errmsg.txt: Merge with 4.1 sql/share/serbian/errmsg.txt: Merge with 4.1 sql/share/slovak/errmsg.txt: Merge with 4.1 sql/share/spanish/errmsg.txt: Merge with 4.1 sql/share/swedish/errmsg.txt: Merge with 4.1 sql/share/ukrainian/errmsg.txt: Merge with 4.1 sql/sql_base.cc: Merge with 4.1 sql/sql_class.cc: Merge with 4.1 Use arena code from 4.1 sql/sql_class.h: Merge with 4.1 Use arena code from 4.1 sql/sql_derived.cc: Merge with 4.1 sql/sql_lex.cc: Merge with 4.1 sql/sql_lex.h: Merge with 4.1 sql/sql_parse.cc: Merge with 4.1 sql/sql_prepare.cc: Merge with 4.1 sql/sql_select.cc: Merge with 4.1 sql/sql_table.cc: Merge with 4.1 sql/sql_union.cc: Merge with 4.1 sql/sql_yacc.yy: Merge with 4.1 sql/tztime.cc: Merge with 4.1 tests/client_test.c: Merge with 4.1
2004-09-06 14:14:10 +02:00
DBUG_ASSERT(fixed == 0) added to fix_fields() sql/item.cc: layout fixed fixed bug in prepared statements with subqueries and outer references sql/item.h: neg_transformer get thd argument to call fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 0) added to fix_fields() fixed Item_in_optimizer fixed flag neg_arguments(), neg_transformer() call fix_field() on created items to avoid bouble fix field or non-called fixfields() sql/item_cmpfunc.h: neg_transformer get thd argument to call fix_fields fixed forgoten cleanup() call of parent class sql/item_func.cc: DBUG_ASSERT(fixed == 0) and fixed flag check added to fix_fields() sql/item_func.h: DBUG_ASSERT(fixed == 0) added to fix_fields() fixed forgoten cleanup() call of parent class sql/item_row.cc: DBUG_ASSERT(fixed == 0) added to fix_fields() added forgoten 'fixed' flag set sql/item_subselect.cc: DBUG_ASSERT(fixed == 0) added to fix_fields() fixed subquery transformation sql/sql_base.cc: check of fixed flag added sql/sql_derived.cc: fixed cleunup union in derived table during EXPLAIN command processing sql/sql_select.cc: thd argument add to function to allow call fix_fields() of new created items fixed EXPLAIN double preparation check of fixed flag added eliminate_not_funcs fixed for corrcet fix_fields call of new created items sql/sql_select.h: thd argument add to function to allow call fix_fields() of new created items sql/sql_union.cc: union processing fixed tests/client_test.c: layout fixed new test of outer references fron subqueries
2004-03-17 13:26:26 +01:00
DBUG_ASSERT(fixed == 0);
engine->set_thd((thd= thd_param));
if (!done_first_fix_fields)
{
done_first_fix_fields= TRUE;
inside_first_fix_fields= TRUE;
upper_refs.empty();
/*
psergey-todo: remove _first_fix_fields calls, we need changes on every
execution
*/
}
MWL#17: Table elimination - Make elimination check to be able detect cases like t.primary_key_col1=othertbl.col AND t.primary_key_col2=func(t.primary_key_col1). These are needed to handle e.g. the case of func() being a correlated subquery that selects the latest value. - If we've removed a condition with subquery predicate, EXPLAIN [EXTENDED] won't show the subquery anymore sql/item.cc: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item.h: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_subselect.cc: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. - Added a comment about possible problem in Item_subselect::walk sql/item_subselect.h: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_sum.cc: MWL#17: Table elimination sql/sql_lex.cc: MWL#17: Table elimination sql/sql_lex.h: MWL#17: Table elimination sql/sql_select.h: MWL#17: Table elimination
2009-06-22 13:46:31 +02:00
eliminated= FALSE;
parent_select= thd_param->lex->current_select;
WL#3817: Simplify string / memory area types and make things more consistent (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c BitKeeper/etc/ignore: added libmysqld/ha_ndbcluster_cond.cc --- added debian/defs.mk debian/control client/completion_hash.cc: Remove not needed casts client/my_readline.h: Remove some old types client/mysql.cc: Simplify types client/mysql_upgrade.c: Remove some old types Update call to dirname_part client/mysqladmin.cc: Remove some old types client/mysqlbinlog.cc: Remove some old types Change some buffers to be uchar to avoid casts client/mysqlcheck.c: Remove some old types client/mysqldump.c: Remove some old types Remove some not needed casts Change some string lengths to size_t client/mysqlimport.c: Remove some old types client/mysqlshow.c: Remove some old types client/mysqlslap.c: Remove some old types Remove some not needed casts client/mysqltest.c: Removed some old types Removed some not needed casts Updated hash-get-key function arguments Updated parameters to dirname_part() client/readline.cc: Removed some old types Removed some not needed casts Changed some string lengths to use size_t client/sql_string.cc: Removed some old types dbug/dbug.c: Removed some old types Changed some string lengths to use size_t Changed some prototypes to avoid casts extra/comp_err.c: Removed some old types extra/innochecksum.c: Removed some old types extra/my_print_defaults.c: Removed some old types extra/mysql_waitpid.c: Removed some old types extra/perror.c: Removed some old types extra/replace.c: Removed some old types Updated parameters to dirname_part() extra/resolve_stack_dump.c: Removed some old types extra/resolveip.c: Removed some old types include/config-win.h: Removed some old types include/decimal.h: Changed binary strings to be uchar* instead of char* include/ft_global.h: Removed some old types include/hash.h: Removed some old types include/heap.h: Removed some old types Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable include/keycache.h: Removed some old types include/m_ctype.h: Removed some old types Changed some string lengths to use size_t Changed character length functions to return uint unsigned char -> uchar include/m_string.h: Removed some old types Changed some string lengths to use size_t include/my_alloc.h: Changed some string lengths to use size_t include/my_base.h: Removed some old types include/my_dbug.h: Removed some old types Changed some string lengths to use size_t Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage include/my_getopt.h: Removed some old types include/my_global.h: Removed old types: my_size_t -> size_t byte -> uchar gptr -> uchar * include/my_list.h: Removed some old types include/my_nosys.h: Removed some old types include/my_pthread.h: Removed some old types include/my_sys.h: Removed some old types Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read() Changed some string lengths to use size_t my_malloc() / my_free() now uses void * Updated parameters to dirname_part() & my_uncompress() include/my_tree.h: Removed some old types include/my_trie.h: Removed some old types include/my_user.h: Changed some string lengths to use size_t include/my_vle.h: Removed some old types include/my_xml.h: Removed some old types Changed some string lengths to use size_t include/myisam.h: Removed some old types include/myisammrg.h: Removed some old types include/mysql.h: Removed some old types Changed byte streams to use uchar* instead of char* include/mysql_com.h: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts include/queues.h: Removed some old types include/sql_common.h: Removed some old types include/sslopt-longopts.h: Removed some old types include/violite.h: Removed some old types Changed some string lengths to use size_t libmysql/client_settings.h: Removed some old types libmysql/libmysql.c: Removed some old types libmysql/manager.c: Removed some old types libmysqld/emb_qcache.cc: Removed some old types libmysqld/emb_qcache.h: Removed some old types libmysqld/lib_sql.cc: Removed some old types Removed some not needed casts Changed some buffers to be uchar* to avoid casts true -> TRUE, false -> FALSE mysys/array.c: Removed some old types mysys/charset.c: Changed some string lengths to use size_t mysys/checksum.c: Include zlib to get definition for crc32 Removed some old types mysys/default.c: Removed some old types Changed some string lengths to use size_t mysys/default_modify.c: Changed some string lengths to use size_t Removed some not needed casts mysys/hash.c: Removed some old types Changed some string lengths to use size_t Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function. hash_element now takes 'ulong' as the index type (cleanup) mysys/list.c: Removed some old types mysys/mf_cache.c: Changed some string lengths to use size_t mysys/mf_dirname.c: Removed some old types Changed some string lengths to use size_t Added argument to dirname_part() to avoid calculation of length for 'to' mysys/mf_fn_ext.c: Removed some old types Updated parameters to dirname_part() mysys/mf_format.c: Removed some old types Changed some string lengths to use size_t mysys/mf_getdate.c: Removed some old types mysys/mf_iocache.c: Removed some old types Changed some string lengths to use size_t Changed calculation of 'max_length' to be done the same way in all functions mysys/mf_iocache2.c: Removed some old types Changed some string lengths to use size_t Clean up comments Removed not needed indentation mysys/mf_keycache.c: Removed some old types mysys/mf_keycaches.c: Removed some old types mysys/mf_loadpath.c: Removed some old types mysys/mf_pack.c: Removed some old types Changed some string lengths to use size_t Removed some not needed casts Removed very old VMS code Updated parameters to dirname_part() Use result of dirnam_part() to remove call to strcat() mysys/mf_path.c: Removed some old types mysys/mf_radix.c: Removed some old types mysys/mf_same.c: Removed some old types mysys/mf_sort.c: Removed some old types mysys/mf_soundex.c: Removed some old types mysys/mf_strip.c: Removed some old types mysys/mf_tempdir.c: Removed some old types mysys/mf_unixpath.c: Removed some old types mysys/mf_wfile.c: Removed some old types mysys/mulalloc.c: Removed some old types mysys/my_alloc.c: Removed some old types Changed some string lengths to use size_t Use void* as type for allocated memory area Removed some not needed casts Changed argument 'Size' to 'length' according coding guidelines mysys/my_chsize.c: Changed some buffers to be uchar* to avoid casts mysys/my_compress.c: More comments Removed some old types Changed string lengths to use size_t Changed arguments to my_uncompress() to make them easier to understand Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) Changed type of 'pack_data' argument to packfrm() to avoid casts. mysys/my_conio.c: Changed some string lengths to use size_t mysys/my_create.c: Removed some old types mysys/my_div.c: Removed some old types mysys/my_error.c: Removed some old types mysys/my_fopen.c: Removed some old types mysys/my_fstream.c: Removed some old types Changed some string lengths to use size_t writen -> written mysys/my_getopt.c: Removed some old types mysys/my_getwd.c: Removed some old types More comments mysys/my_init.c: Removed some old types mysys/my_largepage.c: Removed some old types Changed some string lengths to use size_t mysys/my_lib.c: Removed some old types mysys/my_lockmem.c: Removed some old types mysys/my_malloc.c: Removed some old types Changed malloc(), free() and related functions to use void * Changed all functions to use size_t mysys/my_memmem.c: Indentation cleanup mysys/my_once.c: Removed some old types Changed malloc(), free() and related functions to use void * mysys/my_open.c: Removed some old types mysys/my_pread.c: Removed some old types Changed all functions to use size_t Added comment for how my_pread() / my_pwrite() are supposed to work. Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. (If we ever would really need this, it should be enabled only with a flag argument) mysys/my_quick.c: Removed some old types Changed all functions to use size_t mysys/my_read.c: Removed some old types Changed all functions to use size_t mysys/my_realloc.c: Removed some old types Use void* as type for allocated memory area Changed all functions to use size_t mysys/my_static.c: Removed some old types mysys/my_static.h: Removed some old types mysys/my_vle.c: Removed some old types mysys/my_wincond.c: Removed some old types mysys/my_windac.c: Removed some old types mysys/my_write.c: Removed some old types Changed all functions to use size_t mysys/ptr_cmp.c: Removed some old types Changed all functions to use size_t mysys/queues.c: Removed some old types mysys/safemalloc.c: Removed some old types Changed malloc(), free() and related functions to use void * Changed all functions to use size_t mysys/string.c: Removed some old types Changed all functions to use size_t mysys/testhash.c: Removed some old types mysys/thr_alarm.c: Removed some old types mysys/thr_lock.c: Removed some old types mysys/tree.c: Removed some old types mysys/trie.c: Removed some old types mysys/typelib.c: Removed some old types plugin/daemon_example/daemon_example.cc: Removed some old types regex/reginit.c: Removed some old types server-tools/instance-manager/buffer.cc: Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/buffer.h: Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/commands.cc: Removed some old types Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/instance_map.cc: Removed some old types Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/instance_options.cc: Changed buffer to be of type uchar* Replaced alloc_root + strcpy() with strdup_root() server-tools/instance-manager/mysql_connection.cc: Changed buffer to be of type uchar* server-tools/instance-manager/options.cc: Removed some old types server-tools/instance-manager/parse.cc: Changed some string lengths to use size_t server-tools/instance-manager/parse.h: Removed some old types Changed some string lengths to use size_t server-tools/instance-manager/protocol.cc: Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t server-tools/instance-manager/protocol.h: Changed some string lengths to use size_t server-tools/instance-manager/user_map.cc: Removed some old types Changed some string lengths to use size_t sql/derror.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/discover.cc: Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts sql/event_data_objects.cc: Removed some old types Added missing casts for alloc() and sprintf() sql/event_db_repository.cc: Changed some buffers to be uchar* to avoid casts Added missing casts for sprintf() sql/event_queue.cc: Removed some old types sql/field.cc: Removed some old types Changed memory buffers to be uchar* Changed some string lengths to use size_t Removed a lot of casts Safety fix in Field_blob::val_decimal() to not access zero pointer sql/field.h: Removed some old types Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes). Changed some string lengths to use size_t Removed some not needed casts Changed val_xxx(xxx, new_ptr) to take const pointers sql/field_conv.cc: Removed some old types Added casts required because memory area pointers are now uchar* sql/filesort.cc: Initalize variable that was used unitialized in error conditions sql/gen_lex_hash.cc: Removed some old types Changed memory buffers to be uchar* Changed some string lengths to use size_t Removed a lot of casts Safety fix in Field_blob::val_decimal() to not access zero pointer sql/gstream.h: Added required cast sql/ha_ndbcluster.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts Added required casts Removed some not needed casts sql/ha_ndbcluster.h: Removed some old types sql/ha_ndbcluster_binlog.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake() Changed some string lengths to use size_t Added missing casts for alloc() and sprintf() sql/ha_ndbcluster_binlog.h: Removed some old types sql/ha_ndbcluster_cond.cc: Removed some old types Removed some not needed casts sql/ha_ndbcluster_cond.h: Removed some old types sql/ha_partition.cc: Removed some old types Changed prototype for change_partition() to avoid casts sql/ha_partition.h: Removed some old types sql/handler.cc: Removed some old types Changed some string lengths to use size_t sql/handler.h: Removed some old types Changed some string lengths to use size_t Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts sql/hash_filo.h: Removed some old types Changed all functions to use size_t sql/hostname.cc: Removed some old types sql/item.cc: Removed some old types Changed some string lengths to use size_t Use strmake() instead of memdup() to create a null terminated string. Updated calls to new Field() sql/item.h: Removed some old types Changed malloc(), free() and related functions to use void * Changed some buffers to be uchar* to avoid casts sql/item_cmpfunc.cc: Removed some old types Changed some buffers to be uchar* to avoid casts sql/item_cmpfunc.h: Removed some old types sql/item_create.cc: Removed some old types sql/item_func.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added test for failing alloc() in init_result_field() Remove old confusing comment Fixed compiler warning sql/item_func.h: Removed some old types sql/item_row.cc: Removed some old types sql/item_row.h: Removed some old types sql/item_strfunc.cc: Include zlib (needed becasue we call crc32) Removed some old types sql/item_strfunc.h: Removed some old types Changed some types to match new function prototypes sql/item_subselect.cc: Removed some old types sql/item_subselect.h: Removed some old types sql/item_sum.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/item_sum.h: Removed some old types sql/item_timefunc.cc: Removed some old types Changed some string lengths to use size_t sql/item_timefunc.h: Removed some old types sql/item_xmlfunc.cc: Changed some string lengths to use size_t sql/item_xmlfunc.h: Removed some old types sql/key.cc: Removed some old types Removed some not needed casts sql/lock.cc: Removed some old types Added some cast to my_multi_malloc() arguments for safety sql/log.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Changed usage of pwrite() to not assume it holds the cursor position for the file Made usage of my_read() safer sql/log_event.cc: Removed some old types Added checking of return value of malloc() in pack_info() Changed some buffers to be uchar* to avoid casts Removed some 'const' to avoid casts Added missing casts for alloc() and sprintf() Added required casts Removed some not needed casts Added some cast to my_multi_malloc() arguments for safety sql/log_event.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/log_event_old.cc: Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/log_event_old.h: Changed some buffers to be uchar* to avoid casts sql/mf_iocache.cc: Removed some old types sql/my_decimal.cc: Changed memory area to use uchar* sql/my_decimal.h: Changed memory area to use uchar* sql/mysql_priv.h: Removed some old types Changed malloc(), free() and related functions to use void * Changed some string lengths to use size_t Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow Changed some buffers to be uchar* to avoid casts sql/mysqld.cc: Removed some old types sql/net_serv.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Ensure that vio_read()/vio_write() return values are stored in a size_t variable Removed some not needed casts sql/opt_range.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/opt_range.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/opt_sum.cc: Removed some old types Removed some not needed casts sql/parse_file.cc: Removed some old types Changed some string lengths to use size_t Changed alloc_root + memcpy + set end 0 -> strmake_root() sql/parse_file.h: Removed some old types sql/partition_info.cc: Removed some old types Added missing casts for alloc() Changed some buffers to be uchar* to avoid casts sql/partition_info.h: Changed some buffers to be uchar* to avoid casts sql/protocol.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/protocol.h: Removed some old types Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/records.cc: Removed some old types sql/repl_failsafe.cc: Removed some old types Changed some string lengths to use size_t Added required casts sql/rpl_filter.cc: Removed some old types Updated hash-get-key function arguments Changed some string lengths to use size_t sql/rpl_filter.h: Changed some string lengths to use size_t sql/rpl_injector.h: Removed some old types sql/rpl_record.cc: Removed some old types Removed some not needed casts Changed some buffers to be uchar* to avoid casts sql/rpl_record.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/rpl_record_old.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/rpl_record_old.h: Removed some old types Changed some buffers to be uchar* to avoid cast sql/rpl_rli.cc: Removed some old types sql/rpl_tblmap.cc: Removed some old types sql/rpl_tblmap.h: Removed some old types sql/rpl_utility.cc: Removed some old types sql/rpl_utility.h: Removed some old types Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length sql/set_var.cc: Removed some old types Updated parameters to dirname_part() sql/set_var.h: Removed some old types sql/slave.cc: Removed some old types Changed some string lengths to use size_t sql/slave.h: Removed some old types sql/sp.cc: Removed some old types Added missing casts for printf() sql/sp.h: Removed some old types Updated hash-get-key function arguments sql/sp_cache.cc: Removed some old types Added missing casts for printf() Updated hash-get-key function arguments sql/sp_head.cc: Removed some old types Added missing casts for alloc() and printf() Added required casts Updated hash-get-key function arguments sql/sp_head.h: Removed some old types sql/sp_pcontext.cc: Removed some old types sql/sp_pcontext.h: Removed some old types sql/sql_acl.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added required casts sql/sql_analyse.cc: Changed some buffers to be uchar* to avoid casts sql/sql_analyse.h: Changed some buffers to be uchar* to avoid casts sql/sql_array.h: Removed some old types sql/sql_base.cc: Removed some old types Updated hash-get-key function arguments sql/sql_binlog.cc: Removed some old types Added missing casts for printf() sql/sql_cache.cc: Removed some old types Updated hash-get-key function arguments Removed some not needed casts Changed some string lengths to use size_t sql/sql_cache.h: Removed some old types Removed reference to not existing function cache_key() Updated hash-get-key function arguments sql/sql_class.cc: Removed some old types Updated hash-get-key function arguments Added missing casts for alloc() Updated hash-get-key function arguments Moved THD::max_row_length() to table.cc (as it's not depending on THD) Removed some not needed casts sql/sql_class.h: Removed some old types Changed malloc(), free() and related functions to use void * Removed some not needed casts Changed some string lengths to use size_t Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD sql/sql_connect.cc: Removed some old types Added required casts sql/sql_db.cc: Removed some old types Removed some not needed casts Added some cast to my_multi_malloc() arguments for safety Added missing casts for alloc() sql/sql_delete.cc: Removed some old types sql/sql_handler.cc: Removed some old types Updated hash-get-key function arguments Added some cast to my_multi_malloc() arguments for safety sql/sql_help.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_insert.cc: Removed some old types Added missing casts for alloc() and printf() sql/sql_lex.cc: Removed some old types sql/sql_lex.h: Removed some old types Removed some not needed casts sql/sql_list.h: Removed some old types Removed some not needed casts sql/sql_load.cc: Removed some old types Removed compiler warning sql/sql_manager.cc: Removed some old types sql/sql_map.cc: Removed some old types sql/sql_map.h: Removed some old types sql/sql_olap.cc: Removed some old types sql/sql_parse.cc: Removed some old types Trivial move of code lines to make things more readable Changed some string lengths to use size_t Added missing casts for alloc() sql/sql_partition.cc: Removed some old types Removed compiler warnings about not used functions Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_partition.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/sql_plugin.cc: Removed some old types Added missing casts for alloc() Updated hash-get-key function arguments sql/sql_prepare.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Added missing casts for alloc() and printf() sql-common/client.c: Removed some old types Changed some memory areas to use uchar* sql-common/my_user.c: Changed some string lengths to use size_t sql-common/pack.c: Changed some buffers to be uchar* to avoid casts sql/sql_repl.cc: Added required casts Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/sql_select.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some old types sql/sql_select.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/sql_servers.cc: Removed some old types Updated hash-get-key function arguments sql/sql_show.cc: Removed some old types Added missing casts for alloc() Removed some not needed casts sql/sql_string.cc: Removed some old types Added required casts sql/sql_table.cc: Removed some old types Removed compiler warning about not used variable Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_test.cc: Removed some old types sql/sql_trigger.cc: Removed some old types Added missing casts for alloc() sql/sql_udf.cc: Removed some old types Updated hash-get-key function arguments sql/sql_union.cc: Removed some old types sql/sql_update.cc: Removed some old types Removed some not needed casts sql/sql_view.cc: Removed some old types sql/sql_yacc.yy: Removed some old types Changed some string lengths to use size_t Added missing casts for alloc() sql/stacktrace.c: Removed some old types sql/stacktrace.h: Removed some old types sql/structs.h: Removed some old types sql/table.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts Removed setting of LEX_STRING() arguments in declaration Added required casts More function comments Moved max_row_length() here from sql_class.cc/sql_class.h sql/table.h: Removed some old types Changed some string lengths to use size_t sql/thr_malloc.cc: Use void* as type for allocated memory area Changed all functions to use size_t sql/tzfile.h: Changed some buffers to be uchar* to avoid casts sql/tztime.cc: Changed some buffers to be uchar* to avoid casts Updated hash-get-key function arguments Added missing casts for alloc() Removed some not needed casts sql/uniques.cc: Removed some old types Removed some not needed casts sql/unireg.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added missing casts for alloc() storage/archive/archive_reader.c: Removed some old types storage/archive/azio.c: Removed some old types Removed some not needed casts storage/archive/ha_archive.cc: Removed some old types Changed type for 'frmblob' in archive_discover() to match handler Updated hash-get-key function arguments Removed some not needed casts storage/archive/ha_archive.h: Removed some old types storage/blackhole/ha_blackhole.cc: Removed some old types storage/blackhole/ha_blackhole.h: Removed some old types storage/csv/ha_tina.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts storage/csv/ha_tina.h: Removed some old types Removed some not needed casts storage/csv/transparent_file.cc: Removed some old types Changed type of 'bytes_read' to be able to detect read errors Fixed indentation storage/csv/transparent_file.h: Removed some old types storage/example/ha_example.cc: Removed some old types Updated hash-get-key function arguments storage/example/ha_example.h: Removed some old types storage/federated/ha_federated.cc: Removed some old types Updated hash-get-key function arguments Removed some not needed casts storage/federated/ha_federated.h: Removed some old types storage/heap/_check.c: Changed some buffers to be uchar* to avoid casts storage/heap/_rectest.c: Removed some old types storage/heap/ha_heap.cc: Removed some old types storage/heap/ha_heap.h: Removed some old types storage/heap/heapdef.h: Removed some old types storage/heap/hp_block.c: Removed some old types Changed some string lengths to use size_t storage/heap/hp_clear.c: Removed some old types storage/heap/hp_close.c: Removed some old types storage/heap/hp_create.c: Removed some old types storage/heap/hp_delete.c: Removed some old types storage/heap/hp_hash.c: Removed some old types storage/heap/hp_info.c: Removed some old types storage/heap/hp_open.c: Removed some old types storage/heap/hp_rfirst.c: Removed some old types storage/heap/hp_rkey.c: Removed some old types storage/heap/hp_rlast.c: Removed some old types storage/heap/hp_rnext.c: Removed some old types storage/heap/hp_rprev.c: Removed some old types storage/heap/hp_rrnd.c: Removed some old types storage/heap/hp_rsame.c: Removed some old types storage/heap/hp_scan.c: Removed some old types storage/heap/hp_test1.c: Removed some old types storage/heap/hp_test2.c: Removed some old types storage/heap/hp_update.c: Removed some old types storage/heap/hp_write.c: Removed some old types Changed some string lengths to use size_t storage/innobase/handler/ha_innodb.cc: Removed some old types Updated hash-get-key function arguments Added missing casts for alloc() and printf() Removed some not needed casts storage/innobase/handler/ha_innodb.h: Removed some old types storage/myisam/ft_boolean_search.c: Removed some old types storage/myisam/ft_nlq_search.c: Removed some old types storage/myisam/ft_parser.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/ft_static.c: Removed some old types storage/myisam/ft_stopwords.c: Removed some old types storage/myisam/ft_update.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/ftdefs.h: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/fulltext.h: Removed some old types storage/myisam/ha_myisam.cc: Removed some old types storage/myisam/ha_myisam.h: Removed some old types storage/myisam/mi_cache.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/mi_check.c: Removed some old types storage/myisam/mi_checksum.c: Removed some old types storage/myisam/mi_close.c: Removed some old types storage/myisam/mi_create.c: Removed some old types storage/myisam/mi_delete.c: Removed some old types storage/myisam/mi_delete_all.c: Removed some old types storage/myisam/mi_dynrec.c: Removed some old types storage/myisam/mi_extra.c: Removed some old types storage/myisam/mi_key.c: Removed some old types storage/myisam/mi_locking.c: Removed some old types storage/myisam/mi_log.c: Removed some old types storage/myisam/mi_open.c: Removed some old types Removed some not needed casts Check argument of my_write()/my_pwrite() in functions returning int Added casting of string lengths to size_t storage/myisam/mi_packrec.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/mi_page.c: Removed some old types storage/myisam/mi_preload.c: Removed some old types storage/myisam/mi_range.c: Removed some old types storage/myisam/mi_rfirst.c: Removed some old types storage/myisam/mi_rkey.c: Removed some old types storage/myisam/mi_rlast.c: Removed some old types storage/myisam/mi_rnext.c: Removed some old types storage/myisam/mi_rnext_same.c: Removed some old types storage/myisam/mi_rprev.c: Removed some old types storage/myisam/mi_rrnd.c: Removed some old types storage/myisam/mi_rsame.c: Removed some old types storage/myisam/mi_rsamepos.c: Removed some old types storage/myisam/mi_scan.c: Removed some old types storage/myisam/mi_search.c: Removed some old types storage/myisam/mi_static.c: Removed some old types storage/myisam/mi_statrec.c: Removed some old types storage/myisam/mi_test1.c: Removed some old types storage/myisam/mi_test2.c: Removed some old types storage/myisam/mi_test3.c: Removed some old types storage/myisam/mi_unique.c: Removed some old types storage/myisam/mi_update.c: Removed some old types storage/myisam/mi_write.c: Removed some old types storage/myisam/myisam_ftdump.c: Removed some old types storage/myisam/myisamchk.c: Removed some old types storage/myisam/myisamdef.h: Removed some old types storage/myisam/myisamlog.c: Removed some old types Indentation fix storage/myisam/myisampack.c: Removed some old types storage/myisam/rt_index.c: Removed some old types storage/myisam/rt_split.c: Removed some old types storage/myisam/sort.c: Removed some old types storage/myisam/sp_defs.h: Removed some old types storage/myisam/sp_key.c: Removed some old types storage/myisammrg/ha_myisammrg.cc: Removed some old types storage/myisammrg/ha_myisammrg.h: Removed some old types storage/myisammrg/myrg_close.c: Removed some old types storage/myisammrg/myrg_def.h: Removed some old types storage/myisammrg/myrg_delete.c: Removed some old types storage/myisammrg/myrg_open.c: Removed some old types Updated parameters to dirname_part() storage/myisammrg/myrg_queue.c: Removed some old types storage/myisammrg/myrg_rfirst.c: Removed some old types storage/myisammrg/myrg_rkey.c: Removed some old types storage/myisammrg/myrg_rlast.c: Removed some old types storage/myisammrg/myrg_rnext.c: Removed some old types storage/myisammrg/myrg_rnext_same.c: Removed some old types storage/myisammrg/myrg_rprev.c: Removed some old types storage/myisammrg/myrg_rrnd.c: Removed some old types storage/myisammrg/myrg_rsame.c: Removed some old types storage/myisammrg/myrg_update.c: Removed some old types storage/myisammrg/myrg_write.c: Removed some old types storage/ndb/include/util/ndb_opts.h: Removed some old types storage/ndb/src/cw/cpcd/main.cpp: Removed some old types storage/ndb/src/kernel/vm/Configuration.cpp: Removed some old types storage/ndb/src/mgmclient/main.cpp: Removed some old types storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Removed some old types Removed old disabled code storage/ndb/src/mgmsrv/main.cpp: Removed some old types storage/ndb/src/ndbapi/NdbBlob.cpp: Removed some old types storage/ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variable storage/ndb/src/ndbapi/NdbOperationInt.cpp: Added required casts storage/ndb/src/ndbapi/NdbScanOperation.cpp: Added required casts storage/ndb/tools/delete_all.cpp: Removed some old types storage/ndb/tools/desc.cpp: Removed some old types storage/ndb/tools/drop_index.cpp: Removed some old types storage/ndb/tools/drop_tab.cpp: Removed some old types storage/ndb/tools/listTables.cpp: Removed some old types storage/ndb/tools/ndb_config.cpp: Removed some old types storage/ndb/tools/restore/consumer_restore.cpp: Changed some buffers to be uchar* to avoid casts with new defintion of packfrm() storage/ndb/tools/restore/restore_main.cpp: Removed some old types storage/ndb/tools/select_all.cpp: Removed some old types storage/ndb/tools/select_count.cpp: Removed some old types storage/ndb/tools/waiter.cpp: Removed some old types strings/bchange.c: Changed function to use uchar * and size_t strings/bcmp.c: Changed function to use uchar * and size_t strings/bmove512.c: Changed function to use uchar * and size_t strings/bmove_upp.c: Changed function to use uchar * and size_t strings/ctype-big5.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-bin.c: Changed functions to use size_t strings/ctype-cp932.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-czech.c: Fixed indentation Changed functions to use size_t strings/ctype-euc_kr.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-eucjpms.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-gb2312.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-gbk.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-latin1.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-mb.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-simple.c: Changed functions to use size_t Simpler loops for caseup/casedown unsigned int -> uint unsigned char -> uchar strings/ctype-sjis.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-tis620.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-uca.c: Changed functions to use size_t unsigned char -> uchar strings/ctype-ucs2.c: Moved inclusion of stdarg.h to other includes usigned char -> uchar Changed functions to use size_t Changed character length functions to return uint strings/ctype-ujis.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-utf8.c: Changed functions to use size_t unsigned char -> uchar Indentation fixes strings/ctype-win1250ch.c: Indentation fixes Changed functions to use size_t strings/ctype.c: Changed functions to use size_t strings/decimal.c: Changed type for memory argument to uchar * strings/do_ctype.c: Indentation fixes strings/my_strtoll10.c: unsigned char -> uchar strings/my_vsnprintf.c: Changed functions to use size_t strings/r_strinstr.c: Removed some old types Changed functions to use size_t strings/str_test.c: Removed some old types strings/strappend.c: Changed functions to use size_t strings/strcont.c: Removed some old types strings/strfill.c: Removed some old types strings/strinstr.c: Changed functions to use size_t strings/strlen.c: Changed functions to use size_t strings/strmake.c: Changed functions to use size_t strings/strnlen.c: Changed functions to use size_t strings/strnmov.c: Changed functions to use size_t strings/strto.c: unsigned char -> uchar strings/strtod.c: Changed functions to use size_t strings/strxnmov.c: Changed functions to use size_t strings/xml.c: Changed functions to use size_t Indentation fixes tests/mysql_client_test.c: Removed some old types tests/thread_test.c: Removed some old types vio/test-ssl.c: Removed some old types vio/test-sslclient.c: Removed some old types vio/test-sslserver.c: Removed some old types vio/vio.c: Removed some old types vio/vio_priv.h: Removed some old types Changed vio_read()/vio_write() to work with size_t vio/viosocket.c: Changed vio_read()/vio_write() to work with size_t Indentation fixes vio/viossl.c: Changed vio_read()/vio_write() to work with size_t Indentation fixes vio/viosslfactories.c: Removed some old types vio/viotest-ssl.c: Removed some old types win/README: More explanations
2007-05-10 11:59:39 +02:00
if (check_stack_overrun(thd, STACK_MIN_SIZE, (uchar*)&res))
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
return TRUE;
MWL#17: Table elimination - Make elimination check to be able detect cases like t.primary_key_col1=othertbl.col AND t.primary_key_col2=func(t.primary_key_col1). These are needed to handle e.g. the case of func() being a correlated subquery that selects the latest value. - If we've removed a condition with subquery predicate, EXPLAIN [EXTENDED] won't show the subquery anymore sql/item.cc: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item.h: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_subselect.cc: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. - Added a comment about possible problem in Item_subselect::walk sql/item_subselect.h: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_sum.cc: MWL#17: Table elimination sql/sql_lex.cc: MWL#17: Table elimination sql/sql_lex.h: MWL#17: Table elimination sql/sql_select.h: MWL#17: Table elimination
2009-06-22 13:46:31 +02:00
BUG#834534: Assertion `0' failed in replace_where_subcondition with semijoin subquery in HAVING - The problem was that the code that made the check whether the subquery is an AND-part of the WHERE clause didn't work correctly for nested subqueries. In particular, grand-child subquery in HAVING was treated as if it was in the WHERE, which eventually caused an assert when replace_where_subcondition looked for the subquery predicate in the WHERE and couldn't find it there. - The fix: Removed implementation of "thd_marker approach". thd->thd_marker was used to determine the location of subquery predicate: setup_conds() would set accordingly it when making the {where|on_expr}->fix_fields(...) call so that AND-parts of the WHERE/ON clauses can determine they are the AND-parts. Item_cond_or::fix_fields(), Item_func::fix_fields(), Item_subselect::fix_fields (this one was missed), and all other items-that-contain-items had to reset thd->thd_marker before calling fix_fields() for their children items, so that the children can see they are not AND-parts of WHERE/ON. - The "thd_marker approach" required that a lot of code in different locations maintains correct value of thd->thd_marker, so it was replaced with: - The new approach with mark_as_condition_AND_part does not keep context in thd->thd_marker. Instead, setup_conds() now calls {where|on_expr}->mark_as_condition_AND_part() and implementations of that function make sure that: - parts of AND-expressions get the mark_as_condition_AND_part() call - Item_in_subselect objects record that they are AND-parts of WHERE/ON
2011-08-29 17:57:41 +02:00
if (!(res= engine->prepare()))
{
// all transformation is done (used by prepared statements)
changed= 1;
inside_first_fix_fields= FALSE;
/*
Substitute the current item with an Item_in_optimizer that was
created by Item_in_subselect::select_in_like_transformer and
call fix_fields for the substituted item which in turn calls
engine->prepare for the subquery predicate.
*/
if (substitution)
{
/*
If the top item of the WHERE/HAVING condition changed,
set correct WHERE/HAVING for PS.
*/
if (unit->outer_select()->where == (*ref))
unit->outer_select()->where= substitution;
else if (unit->outer_select()->having == (*ref))
unit->outer_select()->having= substitution;
(*ref)= substitution;
substitution->name= name;
substitution->name_length= name_length;
if (have_to_be_excluded)
engine->exclude();
substitution= 0;
thd->where= "checking transformed subquery";
DBUG_ASSERT(fixed == 0) added to fix_fields() sql/item.cc: layout fixed fixed bug in prepared statements with subqueries and outer references sql/item.h: neg_transformer get thd argument to call fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 0) added to fix_fields() fixed Item_in_optimizer fixed flag neg_arguments(), neg_transformer() call fix_field() on created items to avoid bouble fix field or non-called fixfields() sql/item_cmpfunc.h: neg_transformer get thd argument to call fix_fields fixed forgoten cleanup() call of parent class sql/item_func.cc: DBUG_ASSERT(fixed == 0) and fixed flag check added to fix_fields() sql/item_func.h: DBUG_ASSERT(fixed == 0) added to fix_fields() fixed forgoten cleanup() call of parent class sql/item_row.cc: DBUG_ASSERT(fixed == 0) added to fix_fields() added forgoten 'fixed' flag set sql/item_subselect.cc: DBUG_ASSERT(fixed == 0) added to fix_fields() fixed subquery transformation sql/sql_base.cc: check of fixed flag added sql/sql_derived.cc: fixed cleunup union in derived table during EXPLAIN command processing sql/sql_select.cc: thd argument add to function to allow call fix_fields() of new created items fixed EXPLAIN double preparation check of fixed flag added eliminate_not_funcs fixed for corrcet fix_fields call of new created items sql/sql_select.h: thd argument add to function to allow call fix_fields() of new created items sql/sql_union.cc: union processing fixed tests/client_test.c: layout fixed new test of outer references fron subqueries
2004-03-17 13:26:26 +01:00
if (!(*ref)->fixed)
res= (*ref)->fix_fields(thd, ref);
goto end;
}
// Is it one field subselect?
if (engine->cols() > max_columns)
{
fixed error names mysql-test/r/row.result: fixed error message as it was suggested by Peter Gulutzan mysql-test/r/subselect.result: fixed error message as it was suggested by Peter Gulutzan sql/share/czech/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/danish/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/dutch/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/english/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/estonian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/french/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/german/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/greek/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/hungarian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/italian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/japanese/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/korean/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/norwegian-ny/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/norwegian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/polish/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/portuguese/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/romanian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/russian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/serbian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/slovak/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/spanish/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/swedish/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/ukrainian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan
2003-10-06 21:35:05 +02:00
my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
goto end;
}
fix_length_and_dec();
}
else
goto end;
Table definition cache, part 2 The table opening process now works the following way: - Create common TABLE_SHARE object - Read the .frm file and unpack it into the TABLE_SHARE object - Create a TABLE object based on the information in the TABLE_SHARE object and open a handler to the table object Other noteworthy changes: - In TABLE_SHARE the most common strings are now LEX_STRING's - Better error message when table is not found - Variable table_cache is now renamed 'table_open_cache' - New variable 'table_definition_cache' that is the number of table defintions that will be cached - strxnmov() calls are now fixed to avoid overflows - strxnmov() will now always add one end \0 to result - engine objects are now created with a TABLE_SHARE object instead of a TABLE object. - After creating a field object one must call field->init(table) before using it - For a busy system this change will give you: - Less memory usage for table object - Faster opening of tables (if it's has been in use or is in table definition cache) - Allow you to cache many table definitions objects - Faster drop of table mysql-test/mysql-test-run.sh: Fixed some problems with --gdb option Test both with socket and tcp/ip port that all old servers are killed mysql-test/r/flush_table.result: More tests with lock table with 2 threads + flush table mysql-test/r/information_schema.result: Removed old (now wrong) result mysql-test/r/innodb.result: Better error messages (thanks to TDC patch) mysql-test/r/merge.result: Extra flush table test mysql-test/r/ndb_bitfield.result: Better error messages (thanks to TDC patch) mysql-test/r/ndb_partition_error.result: Better error messages (thanks to TDC patch) mysql-test/r/query_cache.result: Remove tables left from old tests mysql-test/r/temp_table.result: Test truncate with temporary tables mysql-test/r/variables.result: Table_cache -> Table_open_cache mysql-test/t/flush_table.test: More tests with lock table with 2 threads + flush table mysql-test/t/merge.test: Extra flush table test mysql-test/t/multi_update.test: Added 'sleep' to make test predictable mysql-test/t/query_cache.test: Remove tables left from old tests mysql-test/t/temp_table.test: Test truncate with temporary tables mysql-test/t/variables.test: Table_cache -> Table_open_cache mysql-test/valgrind.supp: Remove warning that may happens becasue threads dies in different order mysys/hash.c: Fixed wrong DBUG_PRINT mysys/mf_dirname.c: More DBUG mysys/mf_pack.c: Better comment mysys/mf_tempdir.c: More DBUG Ensure that we call cleanup_dirname() on all temporary directory paths. If we don't do this, we will get a failure when comparing temporary table names as in some cases the temporary table name is run through convert_dirname()) mysys/my_alloc.c: Indentation fix sql/examples/ha_example.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_example.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_tina.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_tina.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/field.cc: Update for table definition cache: - Field creation now takes TABLE_SHARE instead of TABLE as argument (This is becasue field definitions are now cached in TABLE_SHARE) When a field is created, one now must call field->init(TABLE) before using it - Use s->db instead of s->table_cache_key - Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE - make_field() takes TABLE_SHARE as argument instead of TABLE - move_field() -> move_field_offset() sql/field.h: Update for table definition cache: - Field creation now takes TABLE_SHARE instead of TABLE as argument (This is becasue field definitions are now cached in TABLE_SHARE) When a field is created, one now must call field->init(TABLE) before using it - Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE - make_field() takes TABLE_SHARE as argument instead of TABLE - move_field() -> move_field_offset() sql/ha_archive.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_archive.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_berkeley.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Changed name of argument create() to not hide internal 'table' variable. table->s -> table_share sql/ha_berkeley.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_blackhole.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_blackhole.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_federated.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Fixed comments Remove index variable and replace with pointers (simple optimization) move_field() -> move_field_offset() Removed some strlen() calls sql/ha_federated.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_heap.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Simplify delete_table() and create() as the given file names are now without extension sql/ha_heap.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_innodb.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_innodb.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_myisam.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Remove not needed fn_format() Fixed for new table->s structure sql/ha_myisam.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_myisammrg.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Don't set 'is_view' for MERGE tables Use new interface to find_temporary_table() sql/ha_myisammrg.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers Added flag HA_NO_COPY_ON_ALTER sql/ha_ndbcluster.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Fixed wrong calls to strxnmov() Give error HA_ERR_TABLE_DEF_CHANGED if table definition has changed drop_table -> intern_drop_table() table->s -> table_share Move part_info to TABLE Fixed comments & DBUG print's New arguments to print_error() sql/ha_ndbcluster.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_partition.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers We can't set up or use part_info when creating handler as there is not yet any table object New ha_intialise() to work with TDC (Done by Mikael) sql/ha_partition.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers Got set_part_info() from Mikael sql/handler.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers ha_delete_table() now also takes database as an argument handler::ha_open() now takes TABLE as argument ha_open() now calls ha_allocate_read_write_set() Simplify ha_allocate_read_write_set() Remove ha_deallocate_read_write_set() Use table_share (Cached by table definition cache) sql/handler.h: New table flag: HA_NO_COPY_ON_ALTER (used by merge tables) Remove ha_deallocate_read_write_set() get_new_handler() now takes TABLE_SHARE as argument ha_delete_table() now gets database as argument sql/item.cc: table_name and db are now LEX_STRING objects When creating fields, we have now have to call field->init(table) move_field -> move_field_offset() sql/item.h: tmp_table_field_from_field_type() now takes an extra paramenter 'fixed_length' to allow one to force usage of CHAR instead of BLOB sql/item_cmpfunc.cc: Fixed call to tmp_table_field_from_field_type() sql/item_create.cc: Assert if new not handled cast type sql/item_func.cc: When creating fields, we have now have to call field->init(table) dummy_table used by 'sp' now needs a TABLE_SHARE object sql/item_subselect.cc: Trivial code cleanups sql/item_sum.cc: When creating fields, we have now have to call field->init(table) sql/item_timefunc.cc: Item_func_str_to_date::tmp_table_field() now replaced by call to tmp_table_field_from_field_type() (see item_timefunc.h) sql/item_timefunc.h: Simply tmp_table_field() sql/item_uniq.cc: When creating fields, we have now have to call field->init(table) sql/key.cc: Added 'KEY' argument to 'find_ref_key' to simplify code sql/lock.cc: More debugging Use create_table_def_key() to create key for table cache Allocate TABLE_SHARE properly when creating name lock Fix that locked_table_name doesn't test same table twice sql/mysql_priv.h: New functions for table definition cache New interfaces to a lot of functions. New faster interface to find_temporary_table() and close_temporary_table() sql/mysqld.cc: Added support for table definition cache of size 'table_def_size' Fixed som calls to strnmov() Changed name of 'table_cache' to 'table_open_cache' sql/opt_range.cc: Use new interfaces Fixed warnings from valgrind sql/parse_file.cc: Safer calls to strxnmov() Fixed typo sql/set_var.cc: Added variable 'table_definition_cache' Variable table_cache renamed to 'table_open_cache' sql/slave.cc: Use new interface sql/sp.cc: Proper use of TABLE_SHARE sql/sp_head.cc: Remove compiler warnings We have now to call field->init(table) sql/sp_head.h: Pointers to parsed strings are now const sql/sql_acl.cc: table_name is now a LEX_STRING sql/sql_base.cc: Main implementation of table definition cache (The #ifdef's are there for the future when table definition cache will replace open table cache) Now table definitions are cached indepndent of open tables, which will speed up things when a table is in use at once from several places Views are not yet cached; For the moment we only cache if a table is a view or not. Faster implementation of find_temorary_table() Replace 'wait_for_refresh()' with the more general function 'wait_for_condition()' Drop table is slightly faster as we can use the table definition cache to know the type of the table sql/sql_cache.cc: table_cache_key and table_name are now LEX_STRING 'sDBUG print fixes sql/sql_class.cc: table_cache_key is now a LEX_STRING safer strxnmov() sql/sql_class.h: Added number of open table shares (table definitions) sql/sql_db.cc: safer strxnmov() sql/sql_delete.cc: Use new interface to find_temporary_table() sql/sql_derived.cc: table_name is now a LEX_STRING sql/sql_handler.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's sql/sql_insert.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's sql/sql_lex.cc: Make parsed string a const (to quickly find out if anything is trying to change the query string) sql/sql_lex.h: Make parsed string a const (to quickly find out if anything is trying to change the query string) sql/sql_load.cc: Safer strxnmov() sql/sql_parse.cc: Better error if wrong DB name sql/sql_partition.cc: part_info moved to TABLE from TABLE_SHARE Indentation changes sql/sql_select.cc: Indentation fixes Call field->init(TABLE) for new created fields Update create_tmp_table() to use TABLE_SHARE properly sql/sql_select.h: Call field->init(TABLE) for new created fields sql/sql_show.cc: table_name is now a LEX_STRING part_info moved to TABLE sql/sql_table.cc: Use table definition cache to speed up delete of tables Fixed calls to functions with new interfaces Don't use 'share_not_to_be_used' Instead of doing openfrm() when doing repair, we now have to call get_table_share() followed by open_table_from_share(). Replace some fn_format() with faster unpack_filename(). Safer strxnmov() part_info is now in TABLE Added Mikaels patch for partition and ALTER TABLE Instead of using 'TABLE_SHARE->is_view' use 'table_flags() & HA_NO_COPY_ON_ALTER sql/sql_test.cc: table_name and table_cache_key are now LEX_STRING's sql/sql_trigger.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's safer strxnmov() Removed compiler warnings sql/sql_update.cc: Call field->init(TABLE) after field is created sql/sql_view.cc: safer strxnmov() Create common TABLE_SHARE object for views to allow us to cache if table is a view sql/structs.h: Added SHOW_TABLE_DEFINITIONS sql/table.cc: Creation and destruct of TABLE_SHARE objects that are common for many TABLE objects The table opening process now works the following way: - Create common TABLE_SHARE object - Read the .frm file and unpack it into the TABLE_SHARE object - Create a TABLE object based on the information in the TABLE_SHARE object and open a handler to the table object open_table_def() is written in such a way that it should be trival to add parsing of the .frm files in new formats sql/table.h: TABLE objects for the same database table now share a common TABLE_SHARE object In TABLE_SHARE the most common strings are now LEX_STRING's sql/unireg.cc: Changed arguments to rea_create_table() to have same order as other functions Call field->init(table) for new created fields sql/unireg.h: Added OPEN_VIEW strings/strxnmov.c: Change strxnmov() to always add end \0 This makes usage of strxnmov() safer as most of MySQL code assumes that strxnmov() will create a null terminated string
2005-11-23 21:45:02 +01:00
if ((uncacheable= engine->uncacheable()))
{
const_item_cache= 0;
if (uncacheable & UNCACHEABLE_RAND)
used_tables_cache|= RAND_TABLE_BIT;
}
prevent using references on sum function (except HAVING clouse of current select) and forward references include/mysqld_error.h: new error message mysql-test/r/subselect.result: new error message mysql-test/t/subselect.test: new error message sql/item.cc: fix_fields indicator test on incorrect references sql/item.h: fix_fields indicator sql/item_cmpfunc.cc: fix_fields indicator sql/item_func.cc: fix_fields indicator sql/item_func.h: fix_fields indicator sql/item_strfunc.cc: fix_fields indicator sql/item_subselect.cc: fix_fields indicator sql/item_sum.cc: fix_fields indicator sql/item_sum.h: fix_fields indicator sql/item_uniq.h: fix_fields indicator sql/share/czech/errmsg.txt: new error message sql/share/danish/errmsg.txt: new error message sql/share/dutch/errmsg.txt: new error message sql/share/english/errmsg.txt: new error message sql/share/estonian/errmsg.txt: new error message sql/share/french/errmsg.txt: new error message sql/share/german/errmsg.txt: new error message sql/share/greek/errmsg.txt: new error message sql/share/hungarian/errmsg.txt: new error message sql/share/italian/errmsg.txt: new error message sql/share/japanese/errmsg.txt: new error message sql/share/korean/errmsg.txt: new error message sql/share/norwegian-ny/errmsg.txt: new error message sql/share/norwegian/errmsg.txt: new error message sql/share/polish/errmsg.txt: new error message sql/share/portuguese/errmsg.txt: new error message sql/share/romanian/errmsg.txt: new error message sql/share/russian/errmsg.txt: new error message sql/share/serbian/errmsg.txt: new error message sql/share/slovak/errmsg.txt: new error message sql/share/spanish/errmsg.txt: new error message sql/share/swedish/errmsg.txt: new error message sql/share/ukrainian/errmsg.txt: new error message
2002-11-21 10:01:33 +01:00
fixed= 1;
Table definition cache, part 2 The table opening process now works the following way: - Create common TABLE_SHARE object - Read the .frm file and unpack it into the TABLE_SHARE object - Create a TABLE object based on the information in the TABLE_SHARE object and open a handler to the table object Other noteworthy changes: - In TABLE_SHARE the most common strings are now LEX_STRING's - Better error message when table is not found - Variable table_cache is now renamed 'table_open_cache' - New variable 'table_definition_cache' that is the number of table defintions that will be cached - strxnmov() calls are now fixed to avoid overflows - strxnmov() will now always add one end \0 to result - engine objects are now created with a TABLE_SHARE object instead of a TABLE object. - After creating a field object one must call field->init(table) before using it - For a busy system this change will give you: - Less memory usage for table object - Faster opening of tables (if it's has been in use or is in table definition cache) - Allow you to cache many table definitions objects - Faster drop of table mysql-test/mysql-test-run.sh: Fixed some problems with --gdb option Test both with socket and tcp/ip port that all old servers are killed mysql-test/r/flush_table.result: More tests with lock table with 2 threads + flush table mysql-test/r/information_schema.result: Removed old (now wrong) result mysql-test/r/innodb.result: Better error messages (thanks to TDC patch) mysql-test/r/merge.result: Extra flush table test mysql-test/r/ndb_bitfield.result: Better error messages (thanks to TDC patch) mysql-test/r/ndb_partition_error.result: Better error messages (thanks to TDC patch) mysql-test/r/query_cache.result: Remove tables left from old tests mysql-test/r/temp_table.result: Test truncate with temporary tables mysql-test/r/variables.result: Table_cache -> Table_open_cache mysql-test/t/flush_table.test: More tests with lock table with 2 threads + flush table mysql-test/t/merge.test: Extra flush table test mysql-test/t/multi_update.test: Added 'sleep' to make test predictable mysql-test/t/query_cache.test: Remove tables left from old tests mysql-test/t/temp_table.test: Test truncate with temporary tables mysql-test/t/variables.test: Table_cache -> Table_open_cache mysql-test/valgrind.supp: Remove warning that may happens becasue threads dies in different order mysys/hash.c: Fixed wrong DBUG_PRINT mysys/mf_dirname.c: More DBUG mysys/mf_pack.c: Better comment mysys/mf_tempdir.c: More DBUG Ensure that we call cleanup_dirname() on all temporary directory paths. If we don't do this, we will get a failure when comparing temporary table names as in some cases the temporary table name is run through convert_dirname()) mysys/my_alloc.c: Indentation fix sql/examples/ha_example.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_example.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_tina.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_tina.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/field.cc: Update for table definition cache: - Field creation now takes TABLE_SHARE instead of TABLE as argument (This is becasue field definitions are now cached in TABLE_SHARE) When a field is created, one now must call field->init(TABLE) before using it - Use s->db instead of s->table_cache_key - Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE - make_field() takes TABLE_SHARE as argument instead of TABLE - move_field() -> move_field_offset() sql/field.h: Update for table definition cache: - Field creation now takes TABLE_SHARE instead of TABLE as argument (This is becasue field definitions are now cached in TABLE_SHARE) When a field is created, one now must call field->init(TABLE) before using it - Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE - make_field() takes TABLE_SHARE as argument instead of TABLE - move_field() -> move_field_offset() sql/ha_archive.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_archive.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_berkeley.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Changed name of argument create() to not hide internal 'table' variable. table->s -> table_share sql/ha_berkeley.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_blackhole.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_blackhole.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_federated.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Fixed comments Remove index variable and replace with pointers (simple optimization) move_field() -> move_field_offset() Removed some strlen() calls sql/ha_federated.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_heap.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Simplify delete_table() and create() as the given file names are now without extension sql/ha_heap.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_innodb.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_innodb.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_myisam.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Remove not needed fn_format() Fixed for new table->s structure sql/ha_myisam.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_myisammrg.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Don't set 'is_view' for MERGE tables Use new interface to find_temporary_table() sql/ha_myisammrg.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers Added flag HA_NO_COPY_ON_ALTER sql/ha_ndbcluster.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Fixed wrong calls to strxnmov() Give error HA_ERR_TABLE_DEF_CHANGED if table definition has changed drop_table -> intern_drop_table() table->s -> table_share Move part_info to TABLE Fixed comments & DBUG print's New arguments to print_error() sql/ha_ndbcluster.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_partition.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers We can't set up or use part_info when creating handler as there is not yet any table object New ha_intialise() to work with TDC (Done by Mikael) sql/ha_partition.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers Got set_part_info() from Mikael sql/handler.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers ha_delete_table() now also takes database as an argument handler::ha_open() now takes TABLE as argument ha_open() now calls ha_allocate_read_write_set() Simplify ha_allocate_read_write_set() Remove ha_deallocate_read_write_set() Use table_share (Cached by table definition cache) sql/handler.h: New table flag: HA_NO_COPY_ON_ALTER (used by merge tables) Remove ha_deallocate_read_write_set() get_new_handler() now takes TABLE_SHARE as argument ha_delete_table() now gets database as argument sql/item.cc: table_name and db are now LEX_STRING objects When creating fields, we have now have to call field->init(table) move_field -> move_field_offset() sql/item.h: tmp_table_field_from_field_type() now takes an extra paramenter 'fixed_length' to allow one to force usage of CHAR instead of BLOB sql/item_cmpfunc.cc: Fixed call to tmp_table_field_from_field_type() sql/item_create.cc: Assert if new not handled cast type sql/item_func.cc: When creating fields, we have now have to call field->init(table) dummy_table used by 'sp' now needs a TABLE_SHARE object sql/item_subselect.cc: Trivial code cleanups sql/item_sum.cc: When creating fields, we have now have to call field->init(table) sql/item_timefunc.cc: Item_func_str_to_date::tmp_table_field() now replaced by call to tmp_table_field_from_field_type() (see item_timefunc.h) sql/item_timefunc.h: Simply tmp_table_field() sql/item_uniq.cc: When creating fields, we have now have to call field->init(table) sql/key.cc: Added 'KEY' argument to 'find_ref_key' to simplify code sql/lock.cc: More debugging Use create_table_def_key() to create key for table cache Allocate TABLE_SHARE properly when creating name lock Fix that locked_table_name doesn't test same table twice sql/mysql_priv.h: New functions for table definition cache New interfaces to a lot of functions. New faster interface to find_temporary_table() and close_temporary_table() sql/mysqld.cc: Added support for table definition cache of size 'table_def_size' Fixed som calls to strnmov() Changed name of 'table_cache' to 'table_open_cache' sql/opt_range.cc: Use new interfaces Fixed warnings from valgrind sql/parse_file.cc: Safer calls to strxnmov() Fixed typo sql/set_var.cc: Added variable 'table_definition_cache' Variable table_cache renamed to 'table_open_cache' sql/slave.cc: Use new interface sql/sp.cc: Proper use of TABLE_SHARE sql/sp_head.cc: Remove compiler warnings We have now to call field->init(table) sql/sp_head.h: Pointers to parsed strings are now const sql/sql_acl.cc: table_name is now a LEX_STRING sql/sql_base.cc: Main implementation of table definition cache (The #ifdef's are there for the future when table definition cache will replace open table cache) Now table definitions are cached indepndent of open tables, which will speed up things when a table is in use at once from several places Views are not yet cached; For the moment we only cache if a table is a view or not. Faster implementation of find_temorary_table() Replace 'wait_for_refresh()' with the more general function 'wait_for_condition()' Drop table is slightly faster as we can use the table definition cache to know the type of the table sql/sql_cache.cc: table_cache_key and table_name are now LEX_STRING 'sDBUG print fixes sql/sql_class.cc: table_cache_key is now a LEX_STRING safer strxnmov() sql/sql_class.h: Added number of open table shares (table definitions) sql/sql_db.cc: safer strxnmov() sql/sql_delete.cc: Use new interface to find_temporary_table() sql/sql_derived.cc: table_name is now a LEX_STRING sql/sql_handler.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's sql/sql_insert.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's sql/sql_lex.cc: Make parsed string a const (to quickly find out if anything is trying to change the query string) sql/sql_lex.h: Make parsed string a const (to quickly find out if anything is trying to change the query string) sql/sql_load.cc: Safer strxnmov() sql/sql_parse.cc: Better error if wrong DB name sql/sql_partition.cc: part_info moved to TABLE from TABLE_SHARE Indentation changes sql/sql_select.cc: Indentation fixes Call field->init(TABLE) for new created fields Update create_tmp_table() to use TABLE_SHARE properly sql/sql_select.h: Call field->init(TABLE) for new created fields sql/sql_show.cc: table_name is now a LEX_STRING part_info moved to TABLE sql/sql_table.cc: Use table definition cache to speed up delete of tables Fixed calls to functions with new interfaces Don't use 'share_not_to_be_used' Instead of doing openfrm() when doing repair, we now have to call get_table_share() followed by open_table_from_share(). Replace some fn_format() with faster unpack_filename(). Safer strxnmov() part_info is now in TABLE Added Mikaels patch for partition and ALTER TABLE Instead of using 'TABLE_SHARE->is_view' use 'table_flags() & HA_NO_COPY_ON_ALTER sql/sql_test.cc: table_name and table_cache_key are now LEX_STRING's sql/sql_trigger.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's safer strxnmov() Removed compiler warnings sql/sql_update.cc: Call field->init(TABLE) after field is created sql/sql_view.cc: safer strxnmov() Create common TABLE_SHARE object for views to allow us to cache if table is a view sql/structs.h: Added SHOW_TABLE_DEFINITIONS sql/table.cc: Creation and destruct of TABLE_SHARE objects that are common for many TABLE objects The table opening process now works the following way: - Create common TABLE_SHARE object - Read the .frm file and unpack it into the TABLE_SHARE object - Create a TABLE object based on the information in the TABLE_SHARE object and open a handler to the table object open_table_def() is written in such a way that it should be trival to add parsing of the .frm files in new formats sql/table.h: TABLE objects for the same database table now share a common TABLE_SHARE object In TABLE_SHARE the most common strings are now LEX_STRING's sql/unireg.cc: Changed arguments to rea_create_table() to have same order as other functions Call field->init(table) for new created fields sql/unireg.h: Added OPEN_VIEW strings/strxnmov.c: Change strxnmov() to always add end \0 This makes usage of strxnmov() safer as most of MySQL code assumes that strxnmov() will create a null terminated string
2005-11-23 21:45:02 +01:00
end:
done_first_fix_fields= FALSE;
inside_first_fix_fields= FALSE;
thd->where= save_where;
return res;
}
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes Changes that requires code changes in other code of other storage engines. (Note that all changes are very straightforward and one should find all issues by compiling a --debug build and fixing all compiler errors and all asserts in field.cc while running the test suite), - New optional handler function introduced: reset() This is called after every DML statement to make it easy for a handler to statement specific cleanups. (The only case it's not called is if force the file to be closed) - handler::extra(HA_EXTRA_RESET) is removed. Code that was there before should be moved to handler::reset() - table->read_set contains a bitmap over all columns that are needed in the query. read_row() and similar functions only needs to read these columns - table->write_set contains a bitmap over all columns that will be updated in the query. write_row() and update_row() only needs to update these columns. The above bitmaps should now be up to date in all context (including ALTER TABLE, filesort()). The handler is informed of any changes to the bitmap after fix_fields() by calling the virtual function handler::column_bitmaps_signal(). If the handler does caching of these bitmaps (instead of using table->read_set, table->write_set), it should redo the caching in this code. as the signal() may be sent several times, it's probably best to set a variable in the signal and redo the caching on read_row() / write_row() if the variable was set. - Removed the read_set and write_set bitmap objects from the handler class - Removed all column bit handling functions from the handler class. (Now one instead uses the normal bitmap functions in my_bitmap.c instead of handler dedicated bitmap functions) - field->query_id is removed. One should instead instead check table->read_set and table->write_set if a field is used in the query. - handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now instead use table->read_set to check for which columns to retrieve. - If a handler needs to call Field->val() or Field->store() on columns that are not used in the query, one should install a temporary all-columns-used map while doing so. For this, we provide the following functions: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); field->val(); dbug_tmp_restore_column_map(table->read_set, old_map); and similar for the write map: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); field->val(); dbug_tmp_restore_column_map(table->write_set, old_map); If this is not done, you will sooner or later hit a DBUG_ASSERT in the field store() / val() functions. (For not DBUG binaries, the dbug_tmp_restore_column_map() and dbug_tmp_restore_column_map() are inline dummy functions and should be optimized away be the compiler). - If one needs to temporary set the column map for all binaries (and not just to avoid the DBUG_ASSERT() in the Field::store() / Field::val() methods) one should use the functions tmp_use_all_columns() and tmp_restore_column_map() instead of the above dbug_ variants. - All 'status' fields in the handler base class (like records, data_file_length etc) are now stored in a 'stats' struct. This makes it easier to know what status variables are provided by the base handler. This requires some trivial variable names in the extra() function. - New virtual function handler::records(). This is called to optimize COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true. (stats.records is not supposed to be an exact value. It's only has to be 'reasonable enough' for the optimizer to be able to choose a good optimization path). - Non virtual handler::init() function added for caching of virtual constants from engine. - Removed has_transactions() virtual method. Now one should instead return HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support transactions. - The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument that is to be used with 'new handler_name()' to allocate the handler in the right area. The xxxx_create_handler() function is also responsible for any initialization of the object before returning. For example, one should change: static handler *myisam_create_handler(TABLE_SHARE *table) { return new ha_myisam(table); } -> static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { return new (mem_root) ha_myisam(table); } - New optional virtual function: use_hidden_primary_key(). This is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined but we don't have a primary key. This allows the handler to take precisions in remembering any hidden primary key to able to update/delete any found row. The default handler marks all columns to be read. - handler::table_flags() now returns a ulonglong (to allow for more flags). - New/changed table_flags() - HA_HAS_RECORDS Set if ::records() is supported - HA_NO_TRANSACTIONS Set if engine doesn't support transactions - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE Set if we should mark all primary key columns for read when reading rows as part of a DELETE statement. If there is no primary key, all columns are marked for read. - HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some cases (based on table->read_set) - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - HA_DUPP_POS Renamed to HA_DUPLICATE_POS - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE Set this if we should mark ALL key columns for read when when reading rows as part of a DELETE statement. In case of an update we will mark all keys for read for which key part changed value. - HA_STATS_RECORDS_IS_EXACT Set this if stats.records is exact. (This saves us some extra records() calls when optimizing COUNT(*)) - Removed table_flags() - HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if handler::records() gives an exact count() and HA_STATS_RECORDS_IS_EXACT if stats.records is exact. - HA_READ_RND_SAME Removed (no one supported this one) - Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk() - Renamed handler::dupp_pos to handler::dup_pos - Removed not used variable handler::sortkey Upper level handler changes: - ha_reset() now does some overall checks and calls ::reset() - ha_table_flags() added. This is a cached version of table_flags(). The cache is updated on engine creation time and updated on open. MySQL level changes (not obvious from the above): - DBUG_ASSERT() added to check that column usage matches what is set in the column usage bit maps. (This found a LOT of bugs in current column marking code). - In 5.1 before, all used columns was marked in read_set and only updated columns was marked in write_set. Now we only mark columns for which we need a value in read_set. - Column bitmaps are created in open_binary_frm() and open_table_from_share(). (Before this was in table.cc) - handler::table_flags() calls are replaced with handler::ha_table_flags() - For calling field->val() you must have the corresponding bit set in table->read_set. For calling field->store() you must have the corresponding bit set in table->write_set. (There are asserts in all store()/val() functions to catch wrong usage) - thd->set_query_id is renamed to thd->mark_used_columns and instead of setting this to an integer value, this has now the values: MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE Changed also all variables named 'set_query_id' to mark_used_columns. - In filesort() we now inform the handler of exactly which columns are needed doing the sort and choosing the rows. - The TABLE_SHARE object has a 'all_set' column bitmap one can use when one needs a column bitmap with all columns set. (This is used for table->use_all_columns() and other places) - The TABLE object has 3 column bitmaps: - def_read_set Default bitmap for columns to be read - def_write_set Default bitmap for columns to be written - tmp_set Can be used as a temporary bitmap when needed. The table object has also two pointer to bitmaps read_set and write_set that the handler should use to find out which columns are used in which way. - count() optimization now calls handler::records() instead of using handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true). - Added extra argument to Item::walk() to indicate if we should also traverse sub queries. - Added TABLE parameter to cp_buffer_from_ref() - Don't close tables created with CREATE ... SELECT but keep them in the table cache. (Faster usage of newly created tables). New interfaces: - table->clear_column_bitmaps() to initialize the bitmaps for tables at start of new statements. - table->column_bitmaps_set() to set up new column bitmaps and signal the handler about this. - table->column_bitmaps_set_no_signal() for some few cases where we need to setup new column bitmaps but don't signal the handler (as the handler has already been signaled about these before). Used for the momement only in opt_range.cc when doing ROR scans. - table->use_all_columns() to install a bitmap where all columns are marked as use in the read and the write set. - table->default_column_bitmaps() to install the normal read and write column bitmaps, but not signaling the handler about this. This is mainly used when creating TABLE instances. - table->mark_columns_needed_for_delete(), table->mark_columns_needed_for_delete() and table->mark_columns_needed_for_insert() to allow us to put additional columns in column usage maps if handler so requires. (The handler indicates what it neads in handler->table_flags()) - table->prepare_for_position() to allow us to tell handler that it needs to read primary key parts to be able to store them in future table->position() calls. (This replaces the table->file->ha_retrieve_all_pk function) - table->mark_auto_increment_column() to tell handler are going to update columns part of any auto_increment key. - table->mark_columns_used_by_index() to mark all columns that is part of an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow it to quickly know that it only needs to read colums that are part of the key. (The handler can also use the column map for detecting this, but simpler/faster handler can just monitor the extra() call). - table->mark_columns_used_by_index_no_reset() to in addition to other columns, also mark all columns that is used by the given key. - table->restore_column_maps_after_mark_index() to restore to default column maps after a call to table->mark_columns_used_by_index(). - New item function register_field_in_read_map(), for marking used columns in table->read_map. Used by filesort() to mark all used columns - Maintain in TABLE->merge_keys set of all keys that are used in query. (Simplices some optimization loops) - Maintain Field->part_of_key_not_clustered which is like Field->part_of_key but the field in the clustered key is not assumed to be part of all index. (used in opt_range.cc for faster loops) - dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map() tmp_use_all_columns() and tmp_restore_column_map() functions to temporally mark all columns as usable. The 'dbug_' version is primarily intended inside a handler when it wants to just call Field:store() & Field::val() functions, but don't need the column maps set for any other usage. (ie:: bitmap_is_set() is never called) - We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set. The reason for this is that if we have a column marked only for write we can't in the MySQL level know if the value changed or not. The reason this worked before was that MySQL marked all to be written columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden bug'. - open_table_from_share() does not anymore setup temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler(). (Simpler, faster code) Bugs fixed: - Column marking was not done correctly in a lot of cases. (ALTER TABLE, when using triggers, auto_increment fields etc) (Could potentially result in wrong values inserted in table handlers relying on that the old column maps or field->set_query_id was correct) Especially when it comes to triggers, there may be cases where the old code would cause lost/wrong values for NDB and/or InnoDB tables. - Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags: OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG. This allowed me to remove some wrong warnings about: "Some non-transactional changed tables couldn't be rolled back" - Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose some warnings about "Some non-transactional changed tables couldn't be rolled back") - Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table() which could cause delete_table to report random failures. - Fixed core dumps for some tests when running with --debug - Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) - slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. - If we get an duplicate row on insert, change column map to read and write all columns while retrying the operation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. - For table handler that doesn't support NULL in keys, we would give an error when creating a primary key with NULL fields, even after the fields has been automaticly converted to NOT NULL. - Creating a primary key on a SPATIAL key, would fail if field was not declared as NOT NULL. Cleanups: - Removed not used condition argument to setup_tables - Removed not needed item function reset_query_id_processor(). - Field->add_index is removed. Now this is instead maintained in (field->flags & FIELD_IN_ADD_INDEX) - Field->fieldnr is removed (use field->field_index instead) - New argument to filesort() to indicate that it should return a set of row pointers (not used columns). This allowed me to remove some references to sql_command in filesort and should also enable us to return column results in some cases where we couldn't before. - Changed column bitmap handling in opt_range.cc to be aligned with TABLE bitmap, which allowed me to use bitmap functions instead of looping over all fields to create some needed bitmaps. (Faster and smaller code) - Broke up found too long lines - Moved some variable declaration at start of function for better code readability. - Removed some not used arguments from functions. (setup_fields(), mysql_prepare_insert_check_table()) - setup_fields() now takes an enum instead of an int for marking columns usage. - For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. - Changed some constants to enum's and define's. - Using separate column read and write sets allows for easier checking of timestamp field was set by statement. - Remove calls to free_io_cache() as this is now done automaticly in ha_reset() - Don't build table->normalized_path as this is now identical to table->path (after bar's fixes to convert filenames) - Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to do comparision with the 'convert-dbug-for-diff' tool. Things left to do in 5.1: - We wrongly log failed CREATE TABLE ... SELECT in some cases when using row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result) Mats has promised to look into this. - Test that my fix for CREATE TABLE ... SELECT is indeed correct. (I added several test cases for this, but in this case it's better that someone else also tests this throughly). Lars has promosed to do this. BitKeeper/etc/ignore: added mysys/test_bitmap include/base64.h: Removed my_global.h, as this must be included first in any program include/heap.h: Added heap_reset() (Required by new handler interface) include/my_base.h: Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET). HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary include/my_bitmap.h: Remove my_pthread.h (should be included at upper level) Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp() Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void include/myisam.h: Added mi_reset() (Required by new handler interface) include/myisammrg.h: Added myrg_reset() (Required by new handler interface) include/mysql_com.h: Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/install_test_db.sh: Simplify ldata usage Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set) mysql-test/mysql-test-run.pl: Added --tmpdir=. to bootstrap mysql-test/mysql-test-run.sh: Use copy instead of INSTALL_DB for master and slave databases. (Speeds up startup time a lot!) Remove snapshot directories at startup (removes some strange warnings) mysql-test/r/binlog_row_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/r/binlog_stm_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment mysql-test/r/create.result: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/r/federated.result: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/r/func_gconcat.result: Enable some disabled tests (converted them slightly to be predictable) mysql-test/r/func_time.result: Added drop of test function mysql-test/r/innodb_mysql.result: Added tests for CREATE ... SELECT mysql-test/r/insert.result: More tests Added testing of duplicate columns in insert mysql-test/r/loaddata.result: Added testing LOAD DATA ... SET ... mysql-test/r/multi_update.result: Test multi updates and deletes using primary key and without mysql-test/r/ndb_index_unique.result: Better error message mysql-test/r/ndb_replace.result: New correct result after fixing REPLACE handling with NDB mysql-test/r/rpl_ddl.result: Now we don't get these (wrong) warnings anymore mysql-test/r/view_grant.result: Drop used views mysql-test/t/create.test: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/t/federated.test: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/t/func_gconcat.test: Enable some disabled tests (converted them slightly to be predictable) mysql-test/t/func_time.test: Added drop of test function mysql-test/t/innodb_mysql.test: Added tests for CREATE ... SELECT mysql-test/t/insert.test: More tests Added testing of duplicate columns in insert mysql-test/t/loaddata.test: Added testing LOAD DATA ... SET ... mysql-test/t/multi_update.test: Test multi updates and deletes using primary key and without mysql-test/t/view_grant.test: Drop used views mysql-test/valgrind.supp: Added supression of not needed warnings when printing stack trace mysys/base64.c: Include my_global.h first mysys/my_bitmap.c: Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy() Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström) Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed. Changed how mutex is allocated to make 'bitmap_free()' function simpler. mysys/thr_lock.c: Added 0x before thread pointers (for easier comparison of DBUG traces) sql/event.cc: Ensure 'use_all_columns()' is used for event tables Don't print warning that event table is damaged if it doesn't exists. sql/field.cc: Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set (Rest of changes are only indentation cleanups) sql/field.h: Removed Field->query_id (replaced by table->read_set and table->write_set) Removed Field->fieldnr (use Field->field_index instead) Removed Field->add_index (Use Field->flags instead) Add Field->part_of_key_not_clustered (for usage in opt_range.cc) sql/filesort.cc: Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set. This allowed me to remove checking of sql_command. Create a temporary column bitmap for fields that are used by the sorting process. Use column bitmaps instead of query_id sql/ha_berkeley.cc: Update to 'newer' table handler interface sql/ha_berkeley.h: Update to 'newer' table handler interface sql/ha_federated.cc: Update to 'newer' table handler interface Only read columns that are needed from remote server. In case of eq ranges, don't generate two conditions in the WHERE clause (this can still be optimized, but would require a bigger code change) Use 'simpler to use' XXXX_LEN' macros A bit simpler logic in ::write_row() when creating statements. In update, only include test of fields actually read. (This greatly simplifies the queries sent by the federated engine) Similar changes done for delete_row() sql/ha_federated.h: Update to 'newer' table handler interface Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE sql/ha_heap.cc: Update to 'newer' table handler interface sql/ha_heap.h: Update to 'newer' table handler interface sql/ha_innodb.cc: Update to 'newer' table handler interface - Update innobase_create_handler() to new interface - Removed HA_NOT_EXACT_COUNT (not needed) - Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - Prefixed base status variables with 'stats' - Use table column bitmaps instead of ha_get_bit_in_read_set() - Added ::reset(), with code from ::extra(HA_EXTRA_RESET) - Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as the table->read_set and table->write_set bitmaps now are accurate sql/ha_innodb.h: Update to 'newer' table handler interface - table_flags are now ulonglong - Added reset() method - Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns. - Made build_template() a class function to be able to easier access class variables sql/ha_myisam.cc: Update to 'newer' table handler interface sql/ha_myisam.h: Update to 'newer' table handler interface sql/ha_myisammrg.cc: Update to 'newer' table handler interface sql/ha_myisammrg.h: Update to 'newer' table handler interface sql/ha_ndbcluster.cc: Update to 'newer' table handler interface Fixed use_blob_value() to be accurate In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map Correct dumping of field data with DBUG_DUMP Prefix addresses in DBUG_PRINT with 0x Fixed usage of not initialized memory Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index. sql/ha_ndbcluster.h: Update to 'newer' table handler interface sql/ha_ndbcluster_binlog.cc: Mark usage of all columns in ndbcluster binlog tables false -> FALSE, true -> TRUE Use table->s->all_set instead of creating a temporary bitmap. sql/ha_partition.cc: Update to 'newer' table handler interface Added memroot to initialise_partitions() and related functions to get faster memory allocation. partition_create_handler() is now responsible for initialisation of the partition object Some trivial optimizations and indentation fixes Ensure that table_flags() are up to date Removed documentation for removed HA_EXTRA flags Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance' sql/ha_partition.h: Update to 'newer' table handler interface sql/handler.cc: create_xxx handler now takes MEMROOT as an argument to simplify memory allocation. Much simpler get_new_handler() (Initialization of the object is now handled by the create method for the engine) Moved all allocation of bitmap handling to the TABLE object (in table.cc) Added column_bitmaps_signal() to signal column usage changes. Changed binlog_log_row() to use the exiusting all_set bitmap in the table object. Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset() Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row sql/handler.h: Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME HA_DUPP_POS -> HA_DUPLICATE_POS HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records() HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION Added future row type 'ROW_TYPE_PAGES' Added MEM_ROOT to handlerton 'create' function Added ha_statistics, a structure for all status variable in the base handler class. Moved all status variables in the handler class into a stats structs to improve readability. ha_table_flags() is now a cached (not virtual) version of table_flags() reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own. Renamed dupp_ref to dup_ref Renamed not used handler::sortkey Moved read_set and write_set to TABLE structure handler::init() function added for cacheing of virtual constants from engine. sql/item.cc: Added register_field_in_read_map() for marking used columns in expression. This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting. Initalize value.cs_info.character_set_client to fix core dump bug with --debug set_query_id -> mark_used_columns Mark used columns in read_set OR write_set. sql/item.h: Removed reset_query_id_processor() as it's not needed anymore. Added register_field_in_read_map() Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_cmpfunc.cc: Temporary mark used columns to be read/writable Update Item::walk to new interface sql/item_cmpfunc.h: Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_func.cc: Update Item::walk() to new interface table_flags() -> ha_table_flags() sql/item_func.h: Update Item::walk() to new interface sql/item_row.cc: Update Item::walk() to new interface sql/item_row.h: Update Item::walk() to new interface sql/item_strfunc.h: Update Item::walk() to new interface sql/item_subselect.cc: Added Item_subselect::walk() (It was a bug it was missing before. Not sure what kind of bugs this could have caused) sql/item_subselect.h: Update Item::walk() to new interface sql/item_sum.cc: Update Item::walk() to new interface Updates for new handler interace sql/item_sum.h: Update Item::walk() to new interface sql/key.cc: Updates for new handler interace sql/log.cc: Mark all columns used for log tables Split options flag Ensured that second argument to trans_register_ha is a bool sql/log_event.cc: Fixed comments to be withing 79 characters Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings Updates for new handler interface Use 0x%lx instead of %p (portability problem) sql/mysql_priv.h: Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback Removed not used 'conds' argument to setup_tables sql/mysqld.cc: Indentation fixes and removed old comment sql/opt_range.cc: Update to new handler and bitmap interface. Fixed calls to cp_buffer_from_ref() and walk() (new argument). Create new temporary bitmaps for ror scans. (Needed because of handler changes and to get more accurate column bitmaps than before) Remove not needed file->ha_reset() call before file->close(). Some trivial optimization and indentation fixes. Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts. Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record. This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling. (This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans) Optimized bitmap handling in ror scans: - Start bitmap at position 0, not 1 - Use same bitmap size as in TABLE - Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table sql/opt_range.h: Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan Added temporary column bitmaps used in ROR scans sql/opt_sum.cc: Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set. sql/protocol.cc: We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user sql/records.cc: Updates for new handler interface sql/set_var.cc: Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags sql/share/errmsg.txt: Fixed wrong sql/sp.cc: Mark that we are using all columns for the proc table Update call to setup_tables() to use new prototype sql/sp_head.cc: Removed QQ comment sql/spatial.cc: Removed wrong QQ comment sql/sql_acl.cc: Mark that we need all columns for acl tables Supply memroot to some 'new' calls. Indentation fixes sql/sql_base.cc: set_query_id removed Ensure we call ha_reset() at end of each statement Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set) Fixed marking of some columns that was not proplerly marked before Maintain in TABLE->merge_keys set of all keys that are used in some way Removed not used 'conds' argument from setup_tables() Remove not used setting of 'dupp_field' in insert_fields() Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) sql/sql_bitmap.h: Added is_overlapping() sql/sql_class.cc: Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. set_query_id -> mark_used_columns Simpler variable usage in pack_row() (cleanup) Moved some variable declartion at start of function for better code readability sql/sql_class.h: Added enum_mark_columns Updated comments Renamed dupp_field -> dup_field Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE. (This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables) sql/sql_delete.cc: Updates to new handler interface Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires. Call table->prepare_for_position() to tell handler that we are going to call ha_position(). Removed call to free_io_cache(). (io_cache is now removed in ha_reset()). Fixed calls to setup_tables() sql/sql_do.cc: Update call to setup_fields() sql/sql_handler.cc: Tell handler tables to always read all columns. Use temporary column map when storing value in field for later index usage sql/sql_help.cc: Makr all used fields to be read Update call to setup_fields() sql/sql_insert.cc: Tell handler we are going to update the auto_increment column dupp_field -> dup_field Set column usage bits for timestamp field. Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column() Removed not used argument from mysql_prepare_insert_check_table(). If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. Setup new bitmaps for delayed insert rows Remove reseting of next_number_fields as it will be reset on next call to handler_insert() Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE. The issue was that one should not to reset this flag as it may be set by a previous statement. The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional. I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done) Don't close tables created with CREATE ... SELECT but keep them in the table cache. Moved out MY_HOOKS from inside function (better readability) sql/sql_load.cc: Update to use new handler and column marking interface Update using setup_tables() sql/sql_olap.cc: Update calls to setup_tables Use enums instead of constants to setup_fields() sql/sql_parse.cc: Handle OPTION_KEEP_LOG: - Set it on CREATE TEMPORARY TABLE / DROP TABLE - Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset - Don't set it for CREATE ... SELECT (this is handled in select_create class) Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset. If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands sql/sql_partition.cc: Update walk() usage Trivial indentation fixes sql/sql_plugin.cc: Mark all columns as used for plugins sql/sql_prepare.cc: Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly) Updates for new handler interface Update calls to setup_fields() sql/sql_repl.cc: Indentation fixes sql/sql_select.cc: Update call to setup_tables() and setup_fields() Remove some old disabled code Update to new hadler interface Indentation cleanups Added column bitmaps for temporary tables. Remove updating of the removed slots in the Field class Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps) For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. sql/sql_select.h: Indentaition fixes. Install temporary column usage maps when needed Added TABLE element to cp_buffer_from_ref() sql/sql_show.cc: Update to new handler interface Mark all columns used for internal tables. Style fixes. Added support for 'future' ROW_TYPE_PAGES. Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly. sql/sql_table.cc: Update to new handler interface Simple my_snprintf -> strmake() Changed some constants to defines Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL) Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX Mark all columns as used for ALTER TABLE Style fixes Update call to filesort() sql/sql_trigger.h: Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in. sql/sql_udf.cc: Mark all columns as used for udf system table. sql/sql_union.cc: Update call to walk() Update to new handler interface sql/sql_update.cc: Remove query_id argument from compare_record() Use column bitmaps instead of query_id. We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value. Update call to setup_fields() Using separate column read and write sets allows for easier checking of timestamp field was set by statement. Removed call to free_io_cache() as this is now done in ha_reset() Call table->mark_columns_needed_for_update() and table->prepare_for_position() Style fixes sql/sql_view.cc: Style fixes sql/table.cc: Remove implicitely include 'errno.h' Remove code for building normalized path, as this is now identical to 'path' Remove field->fieldnr Added update of field->part_of_key_not_clustered() Create column bitmaps in TABLE and TABLE_SHARE Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler() Update to new handler interface Update call to walk() Added new functions: - st_table::clear_column_bitmaps() - st_table::prepare_for_position() - st_table::mark_columns_used_by_index() - st_table::restore_column_maps_after_mark_index() - st_table::mark_columns_used_by_index_no_reset() - st_table::mark_auto_increment_column() - st_table::mark_columns_needed_for_delete() - st_table::mark_columns_needed_for_update() - st_table::mark_columns_needed_for_insert() sql/table.h: Moved column usage bitmaps from handler to TABLE Added to TABLE_SHARE all_set and column_bitmap_size Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set. Declared all new table column bitmap functions Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps() Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val(). sql/tztime.cc: Mark all columns as used for timezone tables storage/archive/ha_archive.cc: Update to new handler interface storage/archive/ha_archive.h: Update to new handler interface storage/blackhole/ha_blackhole.cc: Update to new handler interface storage/blackhole/ha_blackhole.h: Update to new handler interface removed not needed flag HA_DUPP_POS storage/csv/ha_tina.cc: Update to new handler interface storage/csv/ha_tina.h: Update to new handler interface storage/example/ha_example.cc: Update to new handler interface storage/example/ha_example.h: Update to new handler interface storage/heap/hp_extra.c: Added heap_reset() (Required by new handler interface) storage/heap/hp_test2.c: Use heap_reset() storage/myisam/ft_boolean_search.c: Fixed compiler warning storage/myisam/mi_extra.c: Added mi_reset() (Required by new handler interface) storage/myisam/mi_search.c: Fixed DBUG_PRINT messages to use 0x%lx instead of %lx storage/myisam/mi_test2.c: Use mi_reset() storage/myisam/myisampack.c: Use mi_reset() storage/myisammrg/myrg_extra.c: Added myrg_reset() (Required by new handler interface) unittest/mysys/base64.t.c: Include my_global.h Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
bool Item_subselect::enumerate_field_refs_processor(uchar *arg)
MWL#17: Table elimination - Make elimination check to be able detect cases like t.primary_key_col1=othertbl.col AND t.primary_key_col2=func(t.primary_key_col1). These are needed to handle e.g. the case of func() being a correlated subquery that selects the latest value. - If we've removed a condition with subquery predicate, EXPLAIN [EXTENDED] won't show the subquery anymore sql/item.cc: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item.h: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_subselect.cc: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. - Added a comment about possible problem in Item_subselect::walk sql/item_subselect.h: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_sum.cc: MWL#17: Table elimination sql/sql_lex.cc: MWL#17: Table elimination sql/sql_lex.h: MWL#17: Table elimination sql/sql_select.h: MWL#17: Table elimination
2009-06-22 13:46:31 +02:00
{
List_iterator<Ref_to_outside> it(upper_refs);
Ref_to_outside *upper;
while ((upper= it++))
MWL#17: Table elimination - Make elimination check to be able detect cases like t.primary_key_col1=othertbl.col AND t.primary_key_col2=func(t.primary_key_col1). These are needed to handle e.g. the case of func() being a correlated subquery that selects the latest value. - If we've removed a condition with subquery predicate, EXPLAIN [EXTENDED] won't show the subquery anymore sql/item.cc: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item.h: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_subselect.cc: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. - Added a comment about possible problem in Item_subselect::walk sql/item_subselect.h: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_sum.cc: MWL#17: Table elimination sql/sql_lex.cc: MWL#17: Table elimination sql/sql_lex.h: MWL#17: Table elimination sql/sql_select.h: MWL#17: Table elimination
2009-06-22 13:46:31 +02:00
{
if (upper->item->walk(&Item::enumerate_field_refs_processor, FALSE, arg))
MWL#17: Table elimination - Make elimination check to be able detect cases like t.primary_key_col1=othertbl.col AND t.primary_key_col2=func(t.primary_key_col1). These are needed to handle e.g. the case of func() being a correlated subquery that selects the latest value. - If we've removed a condition with subquery predicate, EXPLAIN [EXTENDED] won't show the subquery anymore sql/item.cc: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item.h: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_subselect.cc: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. - Added a comment about possible problem in Item_subselect::walk sql/item_subselect.h: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_sum.cc: MWL#17: Table elimination sql/sql_lex.cc: MWL#17: Table elimination sql/sql_lex.h: MWL#17: Table elimination sql/sql_select.h: MWL#17: Table elimination
2009-06-22 13:46:31 +02:00
return TRUE;
}
return FALSE;
}
bool Item_subselect::mark_as_eliminated_processor(uchar *arg)
{
eliminated= TRUE;
return FALSE;
}
/**
Remove a subselect item from its unit so that the unit no longer
represents a subquery.
@param arg unused parameter
@return
FALSE to force the evaluation of the processor for the subsequent items.
*/
bool Item_subselect::eliminate_subselect_processor(uchar *arg)
{
unit->item= NULL;
unit->exclude_from_tree();
eliminated= TRUE;
return FALSE;
}
/**
Adjust the master select of the subquery to be the fake_select which
represents the whole UNION right above the subquery, instead of the
last query of the UNION.
@param arg pointer to the fake select
@return
FALSE to force the evaluation of the processor for the subsequent items.
*/
bool Item_subselect::set_fake_select_as_master_processor(uchar *arg)
{
SELECT_LEX *fake_select= (SELECT_LEX*) arg;
/*
Move the st_select_lex_unit of a subquery from a global ORDER BY clause to
become a direct child of the fake_select of a UNION. In this way the
ORDER BY that is applied to the temporary table that contains the result of
the whole UNION, and all columns in the subquery are resolved against this
table. The transformation is applied only for immediate child subqueries of
a UNION query.
*/
if (unit->outer_select()->master_unit()->fake_select_lex == fake_select)
{
/*
Set the master of the subquery to be the fake select (i.e. the whole
UNION), instead of the last query in the UNION.
*/
fake_select->add_slave(unit);
DBUG_ASSERT(unit->outer_select() == fake_select);
/* Adjust the name resolution context hierarchy accordingly. */
for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
sl->context.outer_context= &(fake_select->context);
/*
Undo Item_subselect::eliminate_subselect_processor because at that phase
we don't know yet that the ORDER clause will be moved to the fake select.
*/
unit->item= this;
eliminated= FALSE;
}
return FALSE;
}
bool Item_subselect::mark_as_dependent(THD *thd, st_select_lex *select,
Item *item)
{
if (inside_first_fix_fields)
{
is_correlated= TRUE;
Ref_to_outside *upper;
if (!(upper= new (thd->stmt_arena->mem_root) Ref_to_outside()))
return TRUE;
upper->select= select;
upper->item= item;
if (upper_refs.push_back(upper, thd->stmt_arena->mem_root))
return TRUE;
}
return FALSE;
}
/*
Adjust attributes after our parent select has been merged into grandparent
DESCRIPTION
Subquery is a composite object which may be correlated, that is, it may
have
1. references to tables of the parent select (i.e. one that has the clause
with the subquery predicate)
2. references to tables of the grandparent select
3. references to tables of further ancestors.
Before the pullout, this item indicates:
- #1 with table bits in used_tables()
- #2 and #3 with OUTER_REF_TABLE_BIT.
After parent has been merged with grandparent:
- references to parent and grandparent tables should be indicated with
table bits.
- references to greatgrandparent and further ancestors - with
OUTER_REF_TABLE_BIT.
*/
void Item_subselect::fix_after_pullout(st_select_lex *new_parent, Item **ref)
{
recalc_used_tables(new_parent, TRUE);
parent_select= new_parent;
}
class Field_fixer: public Field_enumerator
{
public:
table_map used_tables; /* Collect used_tables here */
st_select_lex *new_parent; /* Select we're in */
virtual void visit_field(Item_field *item)
{
//for (TABLE_LIST *tbl= new_parent->leaf_tables; tbl; tbl= tbl->next_local)
//{
// if (tbl->table == field->table)
// {
used_tables|= item->field->table->map;
// return;
// }
//}
//used_tables |= OUTER_REF_TABLE_BIT;
}
};
/*
Recalculate used_tables_cache
*/
void Item_subselect::recalc_used_tables(st_select_lex *new_parent,
bool after_pullout)
{
List_iterator<Ref_to_outside> it(upper_refs);
Ref_to_outside *upper;
used_tables_cache= 0;
while ((upper= it++))
{
bool found= FALSE;
/*
Check if
1. the upper reference refers to the new immediate parent select, or
2. one of the further ancestors.
We rely on the fact that the tree of selects is modified by some kind of
'flattening', i.e. a process where child selects are merged into their
parents.
The merged selects are removed from the select tree but keep pointers to
their parents.
*/
for (st_select_lex *sel= upper->select; sel; sel= sel->outer_select())
{
/*
If we've reached the new parent select by walking upwards from
reference's original select, this means that the reference is now
referring to the direct parent:
*/
if (sel == new_parent)
{
found= TRUE;
/*
upper->item may be NULL when we've referred to a grouping function,
in which case we don't care about what it's table_map really is,
because item->with_sum_func==1 will ensure correct placement of the
item.
*/
if (upper->item)
{
// Now, iterate over fields and collect used_tables() attribute:
Field_fixer fixer;
fixer.used_tables= 0;
fixer.new_parent= new_parent;
upper->item->walk(&Item::enumerate_field_refs_processor, FALSE,
(uchar*)&fixer);
used_tables_cache |= fixer.used_tables;
upper->item->walk(&Item::update_table_bitmaps_processor, FALSE, NULL);
/*
if (after_pullout)
upper->item->fix_after_pullout(new_parent, &(upper->item));
upper->item->update_used_tables();
*/
}
}
}
if (!found)
used_tables_cache|= OUTER_REF_TABLE_BIT;
}
/*
Don't update const_tables_cache yet as we don't yet know which of the
parent's tables are constant. Parent will call update_used_tables() after
he has done const table detection, and that will be our chance to update
const_tables_cache.
*/
}
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes Changes that requires code changes in other code of other storage engines. (Note that all changes are very straightforward and one should find all issues by compiling a --debug build and fixing all compiler errors and all asserts in field.cc while running the test suite), - New optional handler function introduced: reset() This is called after every DML statement to make it easy for a handler to statement specific cleanups. (The only case it's not called is if force the file to be closed) - handler::extra(HA_EXTRA_RESET) is removed. Code that was there before should be moved to handler::reset() - table->read_set contains a bitmap over all columns that are needed in the query. read_row() and similar functions only needs to read these columns - table->write_set contains a bitmap over all columns that will be updated in the query. write_row() and update_row() only needs to update these columns. The above bitmaps should now be up to date in all context (including ALTER TABLE, filesort()). The handler is informed of any changes to the bitmap after fix_fields() by calling the virtual function handler::column_bitmaps_signal(). If the handler does caching of these bitmaps (instead of using table->read_set, table->write_set), it should redo the caching in this code. as the signal() may be sent several times, it's probably best to set a variable in the signal and redo the caching on read_row() / write_row() if the variable was set. - Removed the read_set and write_set bitmap objects from the handler class - Removed all column bit handling functions from the handler class. (Now one instead uses the normal bitmap functions in my_bitmap.c instead of handler dedicated bitmap functions) - field->query_id is removed. One should instead instead check table->read_set and table->write_set if a field is used in the query. - handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now instead use table->read_set to check for which columns to retrieve. - If a handler needs to call Field->val() or Field->store() on columns that are not used in the query, one should install a temporary all-columns-used map while doing so. For this, we provide the following functions: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); field->val(); dbug_tmp_restore_column_map(table->read_set, old_map); and similar for the write map: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); field->val(); dbug_tmp_restore_column_map(table->write_set, old_map); If this is not done, you will sooner or later hit a DBUG_ASSERT in the field store() / val() functions. (For not DBUG binaries, the dbug_tmp_restore_column_map() and dbug_tmp_restore_column_map() are inline dummy functions and should be optimized away be the compiler). - If one needs to temporary set the column map for all binaries (and not just to avoid the DBUG_ASSERT() in the Field::store() / Field::val() methods) one should use the functions tmp_use_all_columns() and tmp_restore_column_map() instead of the above dbug_ variants. - All 'status' fields in the handler base class (like records, data_file_length etc) are now stored in a 'stats' struct. This makes it easier to know what status variables are provided by the base handler. This requires some trivial variable names in the extra() function. - New virtual function handler::records(). This is called to optimize COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true. (stats.records is not supposed to be an exact value. It's only has to be 'reasonable enough' for the optimizer to be able to choose a good optimization path). - Non virtual handler::init() function added for caching of virtual constants from engine. - Removed has_transactions() virtual method. Now one should instead return HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support transactions. - The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument that is to be used with 'new handler_name()' to allocate the handler in the right area. The xxxx_create_handler() function is also responsible for any initialization of the object before returning. For example, one should change: static handler *myisam_create_handler(TABLE_SHARE *table) { return new ha_myisam(table); } -> static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { return new (mem_root) ha_myisam(table); } - New optional virtual function: use_hidden_primary_key(). This is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined but we don't have a primary key. This allows the handler to take precisions in remembering any hidden primary key to able to update/delete any found row. The default handler marks all columns to be read. - handler::table_flags() now returns a ulonglong (to allow for more flags). - New/changed table_flags() - HA_HAS_RECORDS Set if ::records() is supported - HA_NO_TRANSACTIONS Set if engine doesn't support transactions - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE Set if we should mark all primary key columns for read when reading rows as part of a DELETE statement. If there is no primary key, all columns are marked for read. - HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some cases (based on table->read_set) - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - HA_DUPP_POS Renamed to HA_DUPLICATE_POS - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE Set this if we should mark ALL key columns for read when when reading rows as part of a DELETE statement. In case of an update we will mark all keys for read for which key part changed value. - HA_STATS_RECORDS_IS_EXACT Set this if stats.records is exact. (This saves us some extra records() calls when optimizing COUNT(*)) - Removed table_flags() - HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if handler::records() gives an exact count() and HA_STATS_RECORDS_IS_EXACT if stats.records is exact. - HA_READ_RND_SAME Removed (no one supported this one) - Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk() - Renamed handler::dupp_pos to handler::dup_pos - Removed not used variable handler::sortkey Upper level handler changes: - ha_reset() now does some overall checks and calls ::reset() - ha_table_flags() added. This is a cached version of table_flags(). The cache is updated on engine creation time and updated on open. MySQL level changes (not obvious from the above): - DBUG_ASSERT() added to check that column usage matches what is set in the column usage bit maps. (This found a LOT of bugs in current column marking code). - In 5.1 before, all used columns was marked in read_set and only updated columns was marked in write_set. Now we only mark columns for which we need a value in read_set. - Column bitmaps are created in open_binary_frm() and open_table_from_share(). (Before this was in table.cc) - handler::table_flags() calls are replaced with handler::ha_table_flags() - For calling field->val() you must have the corresponding bit set in table->read_set. For calling field->store() you must have the corresponding bit set in table->write_set. (There are asserts in all store()/val() functions to catch wrong usage) - thd->set_query_id is renamed to thd->mark_used_columns and instead of setting this to an integer value, this has now the values: MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE Changed also all variables named 'set_query_id' to mark_used_columns. - In filesort() we now inform the handler of exactly which columns are needed doing the sort and choosing the rows. - The TABLE_SHARE object has a 'all_set' column bitmap one can use when one needs a column bitmap with all columns set. (This is used for table->use_all_columns() and other places) - The TABLE object has 3 column bitmaps: - def_read_set Default bitmap for columns to be read - def_write_set Default bitmap for columns to be written - tmp_set Can be used as a temporary bitmap when needed. The table object has also two pointer to bitmaps read_set and write_set that the handler should use to find out which columns are used in which way. - count() optimization now calls handler::records() instead of using handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true). - Added extra argument to Item::walk() to indicate if we should also traverse sub queries. - Added TABLE parameter to cp_buffer_from_ref() - Don't close tables created with CREATE ... SELECT but keep them in the table cache. (Faster usage of newly created tables). New interfaces: - table->clear_column_bitmaps() to initialize the bitmaps for tables at start of new statements. - table->column_bitmaps_set() to set up new column bitmaps and signal the handler about this. - table->column_bitmaps_set_no_signal() for some few cases where we need to setup new column bitmaps but don't signal the handler (as the handler has already been signaled about these before). Used for the momement only in opt_range.cc when doing ROR scans. - table->use_all_columns() to install a bitmap where all columns are marked as use in the read and the write set. - table->default_column_bitmaps() to install the normal read and write column bitmaps, but not signaling the handler about this. This is mainly used when creating TABLE instances. - table->mark_columns_needed_for_delete(), table->mark_columns_needed_for_delete() and table->mark_columns_needed_for_insert() to allow us to put additional columns in column usage maps if handler so requires. (The handler indicates what it neads in handler->table_flags()) - table->prepare_for_position() to allow us to tell handler that it needs to read primary key parts to be able to store them in future table->position() calls. (This replaces the table->file->ha_retrieve_all_pk function) - table->mark_auto_increment_column() to tell handler are going to update columns part of any auto_increment key. - table->mark_columns_used_by_index() to mark all columns that is part of an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow it to quickly know that it only needs to read colums that are part of the key. (The handler can also use the column map for detecting this, but simpler/faster handler can just monitor the extra() call). - table->mark_columns_used_by_index_no_reset() to in addition to other columns, also mark all columns that is used by the given key. - table->restore_column_maps_after_mark_index() to restore to default column maps after a call to table->mark_columns_used_by_index(). - New item function register_field_in_read_map(), for marking used columns in table->read_map. Used by filesort() to mark all used columns - Maintain in TABLE->merge_keys set of all keys that are used in query. (Simplices some optimization loops) - Maintain Field->part_of_key_not_clustered which is like Field->part_of_key but the field in the clustered key is not assumed to be part of all index. (used in opt_range.cc for faster loops) - dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map() tmp_use_all_columns() and tmp_restore_column_map() functions to temporally mark all columns as usable. The 'dbug_' version is primarily intended inside a handler when it wants to just call Field:store() & Field::val() functions, but don't need the column maps set for any other usage. (ie:: bitmap_is_set() is never called) - We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set. The reason for this is that if we have a column marked only for write we can't in the MySQL level know if the value changed or not. The reason this worked before was that MySQL marked all to be written columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden bug'. - open_table_from_share() does not anymore setup temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler(). (Simpler, faster code) Bugs fixed: - Column marking was not done correctly in a lot of cases. (ALTER TABLE, when using triggers, auto_increment fields etc) (Could potentially result in wrong values inserted in table handlers relying on that the old column maps or field->set_query_id was correct) Especially when it comes to triggers, there may be cases where the old code would cause lost/wrong values for NDB and/or InnoDB tables. - Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags: OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG. This allowed me to remove some wrong warnings about: "Some non-transactional changed tables couldn't be rolled back" - Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose some warnings about "Some non-transactional changed tables couldn't be rolled back") - Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table() which could cause delete_table to report random failures. - Fixed core dumps for some tests when running with --debug - Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) - slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. - If we get an duplicate row on insert, change column map to read and write all columns while retrying the operation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. - For table handler that doesn't support NULL in keys, we would give an error when creating a primary key with NULL fields, even after the fields has been automaticly converted to NOT NULL. - Creating a primary key on a SPATIAL key, would fail if field was not declared as NOT NULL. Cleanups: - Removed not used condition argument to setup_tables - Removed not needed item function reset_query_id_processor(). - Field->add_index is removed. Now this is instead maintained in (field->flags & FIELD_IN_ADD_INDEX) - Field->fieldnr is removed (use field->field_index instead) - New argument to filesort() to indicate that it should return a set of row pointers (not used columns). This allowed me to remove some references to sql_command in filesort and should also enable us to return column results in some cases where we couldn't before. - Changed column bitmap handling in opt_range.cc to be aligned with TABLE bitmap, which allowed me to use bitmap functions instead of looping over all fields to create some needed bitmaps. (Faster and smaller code) - Broke up found too long lines - Moved some variable declaration at start of function for better code readability. - Removed some not used arguments from functions. (setup_fields(), mysql_prepare_insert_check_table()) - setup_fields() now takes an enum instead of an int for marking columns usage. - For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. - Changed some constants to enum's and define's. - Using separate column read and write sets allows for easier checking of timestamp field was set by statement. - Remove calls to free_io_cache() as this is now done automaticly in ha_reset() - Don't build table->normalized_path as this is now identical to table->path (after bar's fixes to convert filenames) - Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to do comparision with the 'convert-dbug-for-diff' tool. Things left to do in 5.1: - We wrongly log failed CREATE TABLE ... SELECT in some cases when using row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result) Mats has promised to look into this. - Test that my fix for CREATE TABLE ... SELECT is indeed correct. (I added several test cases for this, but in this case it's better that someone else also tests this throughly). Lars has promosed to do this. BitKeeper/etc/ignore: added mysys/test_bitmap include/base64.h: Removed my_global.h, as this must be included first in any program include/heap.h: Added heap_reset() (Required by new handler interface) include/my_base.h: Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET). HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary include/my_bitmap.h: Remove my_pthread.h (should be included at upper level) Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp() Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void include/myisam.h: Added mi_reset() (Required by new handler interface) include/myisammrg.h: Added myrg_reset() (Required by new handler interface) include/mysql_com.h: Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/install_test_db.sh: Simplify ldata usage Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set) mysql-test/mysql-test-run.pl: Added --tmpdir=. to bootstrap mysql-test/mysql-test-run.sh: Use copy instead of INSTALL_DB for master and slave databases. (Speeds up startup time a lot!) Remove snapshot directories at startup (removes some strange warnings) mysql-test/r/binlog_row_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/r/binlog_stm_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment mysql-test/r/create.result: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/r/federated.result: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/r/func_gconcat.result: Enable some disabled tests (converted them slightly to be predictable) mysql-test/r/func_time.result: Added drop of test function mysql-test/r/innodb_mysql.result: Added tests for CREATE ... SELECT mysql-test/r/insert.result: More tests Added testing of duplicate columns in insert mysql-test/r/loaddata.result: Added testing LOAD DATA ... SET ... mysql-test/r/multi_update.result: Test multi updates and deletes using primary key and without mysql-test/r/ndb_index_unique.result: Better error message mysql-test/r/ndb_replace.result: New correct result after fixing REPLACE handling with NDB mysql-test/r/rpl_ddl.result: Now we don't get these (wrong) warnings anymore mysql-test/r/view_grant.result: Drop used views mysql-test/t/create.test: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/t/federated.test: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/t/func_gconcat.test: Enable some disabled tests (converted them slightly to be predictable) mysql-test/t/func_time.test: Added drop of test function mysql-test/t/innodb_mysql.test: Added tests for CREATE ... SELECT mysql-test/t/insert.test: More tests Added testing of duplicate columns in insert mysql-test/t/loaddata.test: Added testing LOAD DATA ... SET ... mysql-test/t/multi_update.test: Test multi updates and deletes using primary key and without mysql-test/t/view_grant.test: Drop used views mysql-test/valgrind.supp: Added supression of not needed warnings when printing stack trace mysys/base64.c: Include my_global.h first mysys/my_bitmap.c: Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy() Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström) Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed. Changed how mutex is allocated to make 'bitmap_free()' function simpler. mysys/thr_lock.c: Added 0x before thread pointers (for easier comparison of DBUG traces) sql/event.cc: Ensure 'use_all_columns()' is used for event tables Don't print warning that event table is damaged if it doesn't exists. sql/field.cc: Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set (Rest of changes are only indentation cleanups) sql/field.h: Removed Field->query_id (replaced by table->read_set and table->write_set) Removed Field->fieldnr (use Field->field_index instead) Removed Field->add_index (Use Field->flags instead) Add Field->part_of_key_not_clustered (for usage in opt_range.cc) sql/filesort.cc: Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set. This allowed me to remove checking of sql_command. Create a temporary column bitmap for fields that are used by the sorting process. Use column bitmaps instead of query_id sql/ha_berkeley.cc: Update to 'newer' table handler interface sql/ha_berkeley.h: Update to 'newer' table handler interface sql/ha_federated.cc: Update to 'newer' table handler interface Only read columns that are needed from remote server. In case of eq ranges, don't generate two conditions in the WHERE clause (this can still be optimized, but would require a bigger code change) Use 'simpler to use' XXXX_LEN' macros A bit simpler logic in ::write_row() when creating statements. In update, only include test of fields actually read. (This greatly simplifies the queries sent by the federated engine) Similar changes done for delete_row() sql/ha_federated.h: Update to 'newer' table handler interface Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE sql/ha_heap.cc: Update to 'newer' table handler interface sql/ha_heap.h: Update to 'newer' table handler interface sql/ha_innodb.cc: Update to 'newer' table handler interface - Update innobase_create_handler() to new interface - Removed HA_NOT_EXACT_COUNT (not needed) - Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - Prefixed base status variables with 'stats' - Use table column bitmaps instead of ha_get_bit_in_read_set() - Added ::reset(), with code from ::extra(HA_EXTRA_RESET) - Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as the table->read_set and table->write_set bitmaps now are accurate sql/ha_innodb.h: Update to 'newer' table handler interface - table_flags are now ulonglong - Added reset() method - Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns. - Made build_template() a class function to be able to easier access class variables sql/ha_myisam.cc: Update to 'newer' table handler interface sql/ha_myisam.h: Update to 'newer' table handler interface sql/ha_myisammrg.cc: Update to 'newer' table handler interface sql/ha_myisammrg.h: Update to 'newer' table handler interface sql/ha_ndbcluster.cc: Update to 'newer' table handler interface Fixed use_blob_value() to be accurate In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map Correct dumping of field data with DBUG_DUMP Prefix addresses in DBUG_PRINT with 0x Fixed usage of not initialized memory Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index. sql/ha_ndbcluster.h: Update to 'newer' table handler interface sql/ha_ndbcluster_binlog.cc: Mark usage of all columns in ndbcluster binlog tables false -> FALSE, true -> TRUE Use table->s->all_set instead of creating a temporary bitmap. sql/ha_partition.cc: Update to 'newer' table handler interface Added memroot to initialise_partitions() and related functions to get faster memory allocation. partition_create_handler() is now responsible for initialisation of the partition object Some trivial optimizations and indentation fixes Ensure that table_flags() are up to date Removed documentation for removed HA_EXTRA flags Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance' sql/ha_partition.h: Update to 'newer' table handler interface sql/handler.cc: create_xxx handler now takes MEMROOT as an argument to simplify memory allocation. Much simpler get_new_handler() (Initialization of the object is now handled by the create method for the engine) Moved all allocation of bitmap handling to the TABLE object (in table.cc) Added column_bitmaps_signal() to signal column usage changes. Changed binlog_log_row() to use the exiusting all_set bitmap in the table object. Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset() Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row sql/handler.h: Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME HA_DUPP_POS -> HA_DUPLICATE_POS HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records() HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION Added future row type 'ROW_TYPE_PAGES' Added MEM_ROOT to handlerton 'create' function Added ha_statistics, a structure for all status variable in the base handler class. Moved all status variables in the handler class into a stats structs to improve readability. ha_table_flags() is now a cached (not virtual) version of table_flags() reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own. Renamed dupp_ref to dup_ref Renamed not used handler::sortkey Moved read_set and write_set to TABLE structure handler::init() function added for cacheing of virtual constants from engine. sql/item.cc: Added register_field_in_read_map() for marking used columns in expression. This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting. Initalize value.cs_info.character_set_client to fix core dump bug with --debug set_query_id -> mark_used_columns Mark used columns in read_set OR write_set. sql/item.h: Removed reset_query_id_processor() as it's not needed anymore. Added register_field_in_read_map() Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_cmpfunc.cc: Temporary mark used columns to be read/writable Update Item::walk to new interface sql/item_cmpfunc.h: Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_func.cc: Update Item::walk() to new interface table_flags() -> ha_table_flags() sql/item_func.h: Update Item::walk() to new interface sql/item_row.cc: Update Item::walk() to new interface sql/item_row.h: Update Item::walk() to new interface sql/item_strfunc.h: Update Item::walk() to new interface sql/item_subselect.cc: Added Item_subselect::walk() (It was a bug it was missing before. Not sure what kind of bugs this could have caused) sql/item_subselect.h: Update Item::walk() to new interface sql/item_sum.cc: Update Item::walk() to new interface Updates for new handler interace sql/item_sum.h: Update Item::walk() to new interface sql/key.cc: Updates for new handler interace sql/log.cc: Mark all columns used for log tables Split options flag Ensured that second argument to trans_register_ha is a bool sql/log_event.cc: Fixed comments to be withing 79 characters Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings Updates for new handler interface Use 0x%lx instead of %p (portability problem) sql/mysql_priv.h: Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback Removed not used 'conds' argument to setup_tables sql/mysqld.cc: Indentation fixes and removed old comment sql/opt_range.cc: Update to new handler and bitmap interface. Fixed calls to cp_buffer_from_ref() and walk() (new argument). Create new temporary bitmaps for ror scans. (Needed because of handler changes and to get more accurate column bitmaps than before) Remove not needed file->ha_reset() call before file->close(). Some trivial optimization and indentation fixes. Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts. Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record. This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling. (This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans) Optimized bitmap handling in ror scans: - Start bitmap at position 0, not 1 - Use same bitmap size as in TABLE - Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table sql/opt_range.h: Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan Added temporary column bitmaps used in ROR scans sql/opt_sum.cc: Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set. sql/protocol.cc: We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user sql/records.cc: Updates for new handler interface sql/set_var.cc: Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags sql/share/errmsg.txt: Fixed wrong sql/sp.cc: Mark that we are using all columns for the proc table Update call to setup_tables() to use new prototype sql/sp_head.cc: Removed QQ comment sql/spatial.cc: Removed wrong QQ comment sql/sql_acl.cc: Mark that we need all columns for acl tables Supply memroot to some 'new' calls. Indentation fixes sql/sql_base.cc: set_query_id removed Ensure we call ha_reset() at end of each statement Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set) Fixed marking of some columns that was not proplerly marked before Maintain in TABLE->merge_keys set of all keys that are used in some way Removed not used 'conds' argument from setup_tables() Remove not used setting of 'dupp_field' in insert_fields() Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) sql/sql_bitmap.h: Added is_overlapping() sql/sql_class.cc: Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. set_query_id -> mark_used_columns Simpler variable usage in pack_row() (cleanup) Moved some variable declartion at start of function for better code readability sql/sql_class.h: Added enum_mark_columns Updated comments Renamed dupp_field -> dup_field Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE. (This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables) sql/sql_delete.cc: Updates to new handler interface Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires. Call table->prepare_for_position() to tell handler that we are going to call ha_position(). Removed call to free_io_cache(). (io_cache is now removed in ha_reset()). Fixed calls to setup_tables() sql/sql_do.cc: Update call to setup_fields() sql/sql_handler.cc: Tell handler tables to always read all columns. Use temporary column map when storing value in field for later index usage sql/sql_help.cc: Makr all used fields to be read Update call to setup_fields() sql/sql_insert.cc: Tell handler we are going to update the auto_increment column dupp_field -> dup_field Set column usage bits for timestamp field. Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column() Removed not used argument from mysql_prepare_insert_check_table(). If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. Setup new bitmaps for delayed insert rows Remove reseting of next_number_fields as it will be reset on next call to handler_insert() Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE. The issue was that one should not to reset this flag as it may be set by a previous statement. The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional. I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done) Don't close tables created with CREATE ... SELECT but keep them in the table cache. Moved out MY_HOOKS from inside function (better readability) sql/sql_load.cc: Update to use new handler and column marking interface Update using setup_tables() sql/sql_olap.cc: Update calls to setup_tables Use enums instead of constants to setup_fields() sql/sql_parse.cc: Handle OPTION_KEEP_LOG: - Set it on CREATE TEMPORARY TABLE / DROP TABLE - Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset - Don't set it for CREATE ... SELECT (this is handled in select_create class) Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset. If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands sql/sql_partition.cc: Update walk() usage Trivial indentation fixes sql/sql_plugin.cc: Mark all columns as used for plugins sql/sql_prepare.cc: Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly) Updates for new handler interface Update calls to setup_fields() sql/sql_repl.cc: Indentation fixes sql/sql_select.cc: Update call to setup_tables() and setup_fields() Remove some old disabled code Update to new hadler interface Indentation cleanups Added column bitmaps for temporary tables. Remove updating of the removed slots in the Field class Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps) For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. sql/sql_select.h: Indentaition fixes. Install temporary column usage maps when needed Added TABLE element to cp_buffer_from_ref() sql/sql_show.cc: Update to new handler interface Mark all columns used for internal tables. Style fixes. Added support for 'future' ROW_TYPE_PAGES. Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly. sql/sql_table.cc: Update to new handler interface Simple my_snprintf -> strmake() Changed some constants to defines Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL) Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX Mark all columns as used for ALTER TABLE Style fixes Update call to filesort() sql/sql_trigger.h: Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in. sql/sql_udf.cc: Mark all columns as used for udf system table. sql/sql_union.cc: Update call to walk() Update to new handler interface sql/sql_update.cc: Remove query_id argument from compare_record() Use column bitmaps instead of query_id. We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value. Update call to setup_fields() Using separate column read and write sets allows for easier checking of timestamp field was set by statement. Removed call to free_io_cache() as this is now done in ha_reset() Call table->mark_columns_needed_for_update() and table->prepare_for_position() Style fixes sql/sql_view.cc: Style fixes sql/table.cc: Remove implicitely include 'errno.h' Remove code for building normalized path, as this is now identical to 'path' Remove field->fieldnr Added update of field->part_of_key_not_clustered() Create column bitmaps in TABLE and TABLE_SHARE Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler() Update to new handler interface Update call to walk() Added new functions: - st_table::clear_column_bitmaps() - st_table::prepare_for_position() - st_table::mark_columns_used_by_index() - st_table::restore_column_maps_after_mark_index() - st_table::mark_columns_used_by_index_no_reset() - st_table::mark_auto_increment_column() - st_table::mark_columns_needed_for_delete() - st_table::mark_columns_needed_for_update() - st_table::mark_columns_needed_for_insert() sql/table.h: Moved column usage bitmaps from handler to TABLE Added to TABLE_SHARE all_set and column_bitmap_size Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set. Declared all new table column bitmap functions Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps() Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val(). sql/tztime.cc: Mark all columns as used for timezone tables storage/archive/ha_archive.cc: Update to new handler interface storage/archive/ha_archive.h: Update to new handler interface storage/blackhole/ha_blackhole.cc: Update to new handler interface storage/blackhole/ha_blackhole.h: Update to new handler interface removed not needed flag HA_DUPP_POS storage/csv/ha_tina.cc: Update to new handler interface storage/csv/ha_tina.h: Update to new handler interface storage/example/ha_example.cc: Update to new handler interface storage/example/ha_example.h: Update to new handler interface storage/heap/hp_extra.c: Added heap_reset() (Required by new handler interface) storage/heap/hp_test2.c: Use heap_reset() storage/myisam/ft_boolean_search.c: Fixed compiler warning storage/myisam/mi_extra.c: Added mi_reset() (Required by new handler interface) storage/myisam/mi_search.c: Fixed DBUG_PRINT messages to use 0x%lx instead of %lx storage/myisam/mi_test2.c: Use mi_reset() storage/myisam/myisampack.c: Use mi_reset() storage/myisammrg/myrg_extra.c: Added myrg_reset() (Required by new handler interface) unittest/mysys/base64.t.c: Include my_global.h Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
bool Item_subselect::walk(Item_processor processor, bool walk_subquery,
WL#3817: Simplify string / memory area types and make things more consistent (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c BitKeeper/etc/ignore: added libmysqld/ha_ndbcluster_cond.cc --- added debian/defs.mk debian/control client/completion_hash.cc: Remove not needed casts client/my_readline.h: Remove some old types client/mysql.cc: Simplify types client/mysql_upgrade.c: Remove some old types Update call to dirname_part client/mysqladmin.cc: Remove some old types client/mysqlbinlog.cc: Remove some old types Change some buffers to be uchar to avoid casts client/mysqlcheck.c: Remove some old types client/mysqldump.c: Remove some old types Remove some not needed casts Change some string lengths to size_t client/mysqlimport.c: Remove some old types client/mysqlshow.c: Remove some old types client/mysqlslap.c: Remove some old types Remove some not needed casts client/mysqltest.c: Removed some old types Removed some not needed casts Updated hash-get-key function arguments Updated parameters to dirname_part() client/readline.cc: Removed some old types Removed some not needed casts Changed some string lengths to use size_t client/sql_string.cc: Removed some old types dbug/dbug.c: Removed some old types Changed some string lengths to use size_t Changed some prototypes to avoid casts extra/comp_err.c: Removed some old types extra/innochecksum.c: Removed some old types extra/my_print_defaults.c: Removed some old types extra/mysql_waitpid.c: Removed some old types extra/perror.c: Removed some old types extra/replace.c: Removed some old types Updated parameters to dirname_part() extra/resolve_stack_dump.c: Removed some old types extra/resolveip.c: Removed some old types include/config-win.h: Removed some old types include/decimal.h: Changed binary strings to be uchar* instead of char* include/ft_global.h: Removed some old types include/hash.h: Removed some old types include/heap.h: Removed some old types Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable include/keycache.h: Removed some old types include/m_ctype.h: Removed some old types Changed some string lengths to use size_t Changed character length functions to return uint unsigned char -> uchar include/m_string.h: Removed some old types Changed some string lengths to use size_t include/my_alloc.h: Changed some string lengths to use size_t include/my_base.h: Removed some old types include/my_dbug.h: Removed some old types Changed some string lengths to use size_t Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage include/my_getopt.h: Removed some old types include/my_global.h: Removed old types: my_size_t -> size_t byte -> uchar gptr -> uchar * include/my_list.h: Removed some old types include/my_nosys.h: Removed some old types include/my_pthread.h: Removed some old types include/my_sys.h: Removed some old types Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read() Changed some string lengths to use size_t my_malloc() / my_free() now uses void * Updated parameters to dirname_part() & my_uncompress() include/my_tree.h: Removed some old types include/my_trie.h: Removed some old types include/my_user.h: Changed some string lengths to use size_t include/my_vle.h: Removed some old types include/my_xml.h: Removed some old types Changed some string lengths to use size_t include/myisam.h: Removed some old types include/myisammrg.h: Removed some old types include/mysql.h: Removed some old types Changed byte streams to use uchar* instead of char* include/mysql_com.h: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts include/queues.h: Removed some old types include/sql_common.h: Removed some old types include/sslopt-longopts.h: Removed some old types include/violite.h: Removed some old types Changed some string lengths to use size_t libmysql/client_settings.h: Removed some old types libmysql/libmysql.c: Removed some old types libmysql/manager.c: Removed some old types libmysqld/emb_qcache.cc: Removed some old types libmysqld/emb_qcache.h: Removed some old types libmysqld/lib_sql.cc: Removed some old types Removed some not needed casts Changed some buffers to be uchar* to avoid casts true -> TRUE, false -> FALSE mysys/array.c: Removed some old types mysys/charset.c: Changed some string lengths to use size_t mysys/checksum.c: Include zlib to get definition for crc32 Removed some old types mysys/default.c: Removed some old types Changed some string lengths to use size_t mysys/default_modify.c: Changed some string lengths to use size_t Removed some not needed casts mysys/hash.c: Removed some old types Changed some string lengths to use size_t Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function. hash_element now takes 'ulong' as the index type (cleanup) mysys/list.c: Removed some old types mysys/mf_cache.c: Changed some string lengths to use size_t mysys/mf_dirname.c: Removed some old types Changed some string lengths to use size_t Added argument to dirname_part() to avoid calculation of length for 'to' mysys/mf_fn_ext.c: Removed some old types Updated parameters to dirname_part() mysys/mf_format.c: Removed some old types Changed some string lengths to use size_t mysys/mf_getdate.c: Removed some old types mysys/mf_iocache.c: Removed some old types Changed some string lengths to use size_t Changed calculation of 'max_length' to be done the same way in all functions mysys/mf_iocache2.c: Removed some old types Changed some string lengths to use size_t Clean up comments Removed not needed indentation mysys/mf_keycache.c: Removed some old types mysys/mf_keycaches.c: Removed some old types mysys/mf_loadpath.c: Removed some old types mysys/mf_pack.c: Removed some old types Changed some string lengths to use size_t Removed some not needed casts Removed very old VMS code Updated parameters to dirname_part() Use result of dirnam_part() to remove call to strcat() mysys/mf_path.c: Removed some old types mysys/mf_radix.c: Removed some old types mysys/mf_same.c: Removed some old types mysys/mf_sort.c: Removed some old types mysys/mf_soundex.c: Removed some old types mysys/mf_strip.c: Removed some old types mysys/mf_tempdir.c: Removed some old types mysys/mf_unixpath.c: Removed some old types mysys/mf_wfile.c: Removed some old types mysys/mulalloc.c: Removed some old types mysys/my_alloc.c: Removed some old types Changed some string lengths to use size_t Use void* as type for allocated memory area Removed some not needed casts Changed argument 'Size' to 'length' according coding guidelines mysys/my_chsize.c: Changed some buffers to be uchar* to avoid casts mysys/my_compress.c: More comments Removed some old types Changed string lengths to use size_t Changed arguments to my_uncompress() to make them easier to understand Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) Changed type of 'pack_data' argument to packfrm() to avoid casts. mysys/my_conio.c: Changed some string lengths to use size_t mysys/my_create.c: Removed some old types mysys/my_div.c: Removed some old types mysys/my_error.c: Removed some old types mysys/my_fopen.c: Removed some old types mysys/my_fstream.c: Removed some old types Changed some string lengths to use size_t writen -> written mysys/my_getopt.c: Removed some old types mysys/my_getwd.c: Removed some old types More comments mysys/my_init.c: Removed some old types mysys/my_largepage.c: Removed some old types Changed some string lengths to use size_t mysys/my_lib.c: Removed some old types mysys/my_lockmem.c: Removed some old types mysys/my_malloc.c: Removed some old types Changed malloc(), free() and related functions to use void * Changed all functions to use size_t mysys/my_memmem.c: Indentation cleanup mysys/my_once.c: Removed some old types Changed malloc(), free() and related functions to use void * mysys/my_open.c: Removed some old types mysys/my_pread.c: Removed some old types Changed all functions to use size_t Added comment for how my_pread() / my_pwrite() are supposed to work. Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. (If we ever would really need this, it should be enabled only with a flag argument) mysys/my_quick.c: Removed some old types Changed all functions to use size_t mysys/my_read.c: Removed some old types Changed all functions to use size_t mysys/my_realloc.c: Removed some old types Use void* as type for allocated memory area Changed all functions to use size_t mysys/my_static.c: Removed some old types mysys/my_static.h: Removed some old types mysys/my_vle.c: Removed some old types mysys/my_wincond.c: Removed some old types mysys/my_windac.c: Removed some old types mysys/my_write.c: Removed some old types Changed all functions to use size_t mysys/ptr_cmp.c: Removed some old types Changed all functions to use size_t mysys/queues.c: Removed some old types mysys/safemalloc.c: Removed some old types Changed malloc(), free() and related functions to use void * Changed all functions to use size_t mysys/string.c: Removed some old types Changed all functions to use size_t mysys/testhash.c: Removed some old types mysys/thr_alarm.c: Removed some old types mysys/thr_lock.c: Removed some old types mysys/tree.c: Removed some old types mysys/trie.c: Removed some old types mysys/typelib.c: Removed some old types plugin/daemon_example/daemon_example.cc: Removed some old types regex/reginit.c: Removed some old types server-tools/instance-manager/buffer.cc: Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/buffer.h: Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/commands.cc: Removed some old types Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/instance_map.cc: Removed some old types Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/instance_options.cc: Changed buffer to be of type uchar* Replaced alloc_root + strcpy() with strdup_root() server-tools/instance-manager/mysql_connection.cc: Changed buffer to be of type uchar* server-tools/instance-manager/options.cc: Removed some old types server-tools/instance-manager/parse.cc: Changed some string lengths to use size_t server-tools/instance-manager/parse.h: Removed some old types Changed some string lengths to use size_t server-tools/instance-manager/protocol.cc: Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t server-tools/instance-manager/protocol.h: Changed some string lengths to use size_t server-tools/instance-manager/user_map.cc: Removed some old types Changed some string lengths to use size_t sql/derror.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/discover.cc: Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts sql/event_data_objects.cc: Removed some old types Added missing casts for alloc() and sprintf() sql/event_db_repository.cc: Changed some buffers to be uchar* to avoid casts Added missing casts for sprintf() sql/event_queue.cc: Removed some old types sql/field.cc: Removed some old types Changed memory buffers to be uchar* Changed some string lengths to use size_t Removed a lot of casts Safety fix in Field_blob::val_decimal() to not access zero pointer sql/field.h: Removed some old types Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes). Changed some string lengths to use size_t Removed some not needed casts Changed val_xxx(xxx, new_ptr) to take const pointers sql/field_conv.cc: Removed some old types Added casts required because memory area pointers are now uchar* sql/filesort.cc: Initalize variable that was used unitialized in error conditions sql/gen_lex_hash.cc: Removed some old types Changed memory buffers to be uchar* Changed some string lengths to use size_t Removed a lot of casts Safety fix in Field_blob::val_decimal() to not access zero pointer sql/gstream.h: Added required cast sql/ha_ndbcluster.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts Added required casts Removed some not needed casts sql/ha_ndbcluster.h: Removed some old types sql/ha_ndbcluster_binlog.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake() Changed some string lengths to use size_t Added missing casts for alloc() and sprintf() sql/ha_ndbcluster_binlog.h: Removed some old types sql/ha_ndbcluster_cond.cc: Removed some old types Removed some not needed casts sql/ha_ndbcluster_cond.h: Removed some old types sql/ha_partition.cc: Removed some old types Changed prototype for change_partition() to avoid casts sql/ha_partition.h: Removed some old types sql/handler.cc: Removed some old types Changed some string lengths to use size_t sql/handler.h: Removed some old types Changed some string lengths to use size_t Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts sql/hash_filo.h: Removed some old types Changed all functions to use size_t sql/hostname.cc: Removed some old types sql/item.cc: Removed some old types Changed some string lengths to use size_t Use strmake() instead of memdup() to create a null terminated string. Updated calls to new Field() sql/item.h: Removed some old types Changed malloc(), free() and related functions to use void * Changed some buffers to be uchar* to avoid casts sql/item_cmpfunc.cc: Removed some old types Changed some buffers to be uchar* to avoid casts sql/item_cmpfunc.h: Removed some old types sql/item_create.cc: Removed some old types sql/item_func.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added test for failing alloc() in init_result_field() Remove old confusing comment Fixed compiler warning sql/item_func.h: Removed some old types sql/item_row.cc: Removed some old types sql/item_row.h: Removed some old types sql/item_strfunc.cc: Include zlib (needed becasue we call crc32) Removed some old types sql/item_strfunc.h: Removed some old types Changed some types to match new function prototypes sql/item_subselect.cc: Removed some old types sql/item_subselect.h: Removed some old types sql/item_sum.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/item_sum.h: Removed some old types sql/item_timefunc.cc: Removed some old types Changed some string lengths to use size_t sql/item_timefunc.h: Removed some old types sql/item_xmlfunc.cc: Changed some string lengths to use size_t sql/item_xmlfunc.h: Removed some old types sql/key.cc: Removed some old types Removed some not needed casts sql/lock.cc: Removed some old types Added some cast to my_multi_malloc() arguments for safety sql/log.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Changed usage of pwrite() to not assume it holds the cursor position for the file Made usage of my_read() safer sql/log_event.cc: Removed some old types Added checking of return value of malloc() in pack_info() Changed some buffers to be uchar* to avoid casts Removed some 'const' to avoid casts Added missing casts for alloc() and sprintf() Added required casts Removed some not needed casts Added some cast to my_multi_malloc() arguments for safety sql/log_event.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/log_event_old.cc: Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/log_event_old.h: Changed some buffers to be uchar* to avoid casts sql/mf_iocache.cc: Removed some old types sql/my_decimal.cc: Changed memory area to use uchar* sql/my_decimal.h: Changed memory area to use uchar* sql/mysql_priv.h: Removed some old types Changed malloc(), free() and related functions to use void * Changed some string lengths to use size_t Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow Changed some buffers to be uchar* to avoid casts sql/mysqld.cc: Removed some old types sql/net_serv.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Ensure that vio_read()/vio_write() return values are stored in a size_t variable Removed some not needed casts sql/opt_range.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/opt_range.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/opt_sum.cc: Removed some old types Removed some not needed casts sql/parse_file.cc: Removed some old types Changed some string lengths to use size_t Changed alloc_root + memcpy + set end 0 -> strmake_root() sql/parse_file.h: Removed some old types sql/partition_info.cc: Removed some old types Added missing casts for alloc() Changed some buffers to be uchar* to avoid casts sql/partition_info.h: Changed some buffers to be uchar* to avoid casts sql/protocol.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/protocol.h: Removed some old types Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/records.cc: Removed some old types sql/repl_failsafe.cc: Removed some old types Changed some string lengths to use size_t Added required casts sql/rpl_filter.cc: Removed some old types Updated hash-get-key function arguments Changed some string lengths to use size_t sql/rpl_filter.h: Changed some string lengths to use size_t sql/rpl_injector.h: Removed some old types sql/rpl_record.cc: Removed some old types Removed some not needed casts Changed some buffers to be uchar* to avoid casts sql/rpl_record.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/rpl_record_old.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/rpl_record_old.h: Removed some old types Changed some buffers to be uchar* to avoid cast sql/rpl_rli.cc: Removed some old types sql/rpl_tblmap.cc: Removed some old types sql/rpl_tblmap.h: Removed some old types sql/rpl_utility.cc: Removed some old types sql/rpl_utility.h: Removed some old types Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length sql/set_var.cc: Removed some old types Updated parameters to dirname_part() sql/set_var.h: Removed some old types sql/slave.cc: Removed some old types Changed some string lengths to use size_t sql/slave.h: Removed some old types sql/sp.cc: Removed some old types Added missing casts for printf() sql/sp.h: Removed some old types Updated hash-get-key function arguments sql/sp_cache.cc: Removed some old types Added missing casts for printf() Updated hash-get-key function arguments sql/sp_head.cc: Removed some old types Added missing casts for alloc() and printf() Added required casts Updated hash-get-key function arguments sql/sp_head.h: Removed some old types sql/sp_pcontext.cc: Removed some old types sql/sp_pcontext.h: Removed some old types sql/sql_acl.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added required casts sql/sql_analyse.cc: Changed some buffers to be uchar* to avoid casts sql/sql_analyse.h: Changed some buffers to be uchar* to avoid casts sql/sql_array.h: Removed some old types sql/sql_base.cc: Removed some old types Updated hash-get-key function arguments sql/sql_binlog.cc: Removed some old types Added missing casts for printf() sql/sql_cache.cc: Removed some old types Updated hash-get-key function arguments Removed some not needed casts Changed some string lengths to use size_t sql/sql_cache.h: Removed some old types Removed reference to not existing function cache_key() Updated hash-get-key function arguments sql/sql_class.cc: Removed some old types Updated hash-get-key function arguments Added missing casts for alloc() Updated hash-get-key function arguments Moved THD::max_row_length() to table.cc (as it's not depending on THD) Removed some not needed casts sql/sql_class.h: Removed some old types Changed malloc(), free() and related functions to use void * Removed some not needed casts Changed some string lengths to use size_t Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD sql/sql_connect.cc: Removed some old types Added required casts sql/sql_db.cc: Removed some old types Removed some not needed casts Added some cast to my_multi_malloc() arguments for safety Added missing casts for alloc() sql/sql_delete.cc: Removed some old types sql/sql_handler.cc: Removed some old types Updated hash-get-key function arguments Added some cast to my_multi_malloc() arguments for safety sql/sql_help.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_insert.cc: Removed some old types Added missing casts for alloc() and printf() sql/sql_lex.cc: Removed some old types sql/sql_lex.h: Removed some old types Removed some not needed casts sql/sql_list.h: Removed some old types Removed some not needed casts sql/sql_load.cc: Removed some old types Removed compiler warning sql/sql_manager.cc: Removed some old types sql/sql_map.cc: Removed some old types sql/sql_map.h: Removed some old types sql/sql_olap.cc: Removed some old types sql/sql_parse.cc: Removed some old types Trivial move of code lines to make things more readable Changed some string lengths to use size_t Added missing casts for alloc() sql/sql_partition.cc: Removed some old types Removed compiler warnings about not used functions Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_partition.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/sql_plugin.cc: Removed some old types Added missing casts for alloc() Updated hash-get-key function arguments sql/sql_prepare.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Added missing casts for alloc() and printf() sql-common/client.c: Removed some old types Changed some memory areas to use uchar* sql-common/my_user.c: Changed some string lengths to use size_t sql-common/pack.c: Changed some buffers to be uchar* to avoid casts sql/sql_repl.cc: Added required casts Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/sql_select.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some old types sql/sql_select.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/sql_servers.cc: Removed some old types Updated hash-get-key function arguments sql/sql_show.cc: Removed some old types Added missing casts for alloc() Removed some not needed casts sql/sql_string.cc: Removed some old types Added required casts sql/sql_table.cc: Removed some old types Removed compiler warning about not used variable Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_test.cc: Removed some old types sql/sql_trigger.cc: Removed some old types Added missing casts for alloc() sql/sql_udf.cc: Removed some old types Updated hash-get-key function arguments sql/sql_union.cc: Removed some old types sql/sql_update.cc: Removed some old types Removed some not needed casts sql/sql_view.cc: Removed some old types sql/sql_yacc.yy: Removed some old types Changed some string lengths to use size_t Added missing casts for alloc() sql/stacktrace.c: Removed some old types sql/stacktrace.h: Removed some old types sql/structs.h: Removed some old types sql/table.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts Removed setting of LEX_STRING() arguments in declaration Added required casts More function comments Moved max_row_length() here from sql_class.cc/sql_class.h sql/table.h: Removed some old types Changed some string lengths to use size_t sql/thr_malloc.cc: Use void* as type for allocated memory area Changed all functions to use size_t sql/tzfile.h: Changed some buffers to be uchar* to avoid casts sql/tztime.cc: Changed some buffers to be uchar* to avoid casts Updated hash-get-key function arguments Added missing casts for alloc() Removed some not needed casts sql/uniques.cc: Removed some old types Removed some not needed casts sql/unireg.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added missing casts for alloc() storage/archive/archive_reader.c: Removed some old types storage/archive/azio.c: Removed some old types Removed some not needed casts storage/archive/ha_archive.cc: Removed some old types Changed type for 'frmblob' in archive_discover() to match handler Updated hash-get-key function arguments Removed some not needed casts storage/archive/ha_archive.h: Removed some old types storage/blackhole/ha_blackhole.cc: Removed some old types storage/blackhole/ha_blackhole.h: Removed some old types storage/csv/ha_tina.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts storage/csv/ha_tina.h: Removed some old types Removed some not needed casts storage/csv/transparent_file.cc: Removed some old types Changed type of 'bytes_read' to be able to detect read errors Fixed indentation storage/csv/transparent_file.h: Removed some old types storage/example/ha_example.cc: Removed some old types Updated hash-get-key function arguments storage/example/ha_example.h: Removed some old types storage/federated/ha_federated.cc: Removed some old types Updated hash-get-key function arguments Removed some not needed casts storage/federated/ha_federated.h: Removed some old types storage/heap/_check.c: Changed some buffers to be uchar* to avoid casts storage/heap/_rectest.c: Removed some old types storage/heap/ha_heap.cc: Removed some old types storage/heap/ha_heap.h: Removed some old types storage/heap/heapdef.h: Removed some old types storage/heap/hp_block.c: Removed some old types Changed some string lengths to use size_t storage/heap/hp_clear.c: Removed some old types storage/heap/hp_close.c: Removed some old types storage/heap/hp_create.c: Removed some old types storage/heap/hp_delete.c: Removed some old types storage/heap/hp_hash.c: Removed some old types storage/heap/hp_info.c: Removed some old types storage/heap/hp_open.c: Removed some old types storage/heap/hp_rfirst.c: Removed some old types storage/heap/hp_rkey.c: Removed some old types storage/heap/hp_rlast.c: Removed some old types storage/heap/hp_rnext.c: Removed some old types storage/heap/hp_rprev.c: Removed some old types storage/heap/hp_rrnd.c: Removed some old types storage/heap/hp_rsame.c: Removed some old types storage/heap/hp_scan.c: Removed some old types storage/heap/hp_test1.c: Removed some old types storage/heap/hp_test2.c: Removed some old types storage/heap/hp_update.c: Removed some old types storage/heap/hp_write.c: Removed some old types Changed some string lengths to use size_t storage/innobase/handler/ha_innodb.cc: Removed some old types Updated hash-get-key function arguments Added missing casts for alloc() and printf() Removed some not needed casts storage/innobase/handler/ha_innodb.h: Removed some old types storage/myisam/ft_boolean_search.c: Removed some old types storage/myisam/ft_nlq_search.c: Removed some old types storage/myisam/ft_parser.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/ft_static.c: Removed some old types storage/myisam/ft_stopwords.c: Removed some old types storage/myisam/ft_update.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/ftdefs.h: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/fulltext.h: Removed some old types storage/myisam/ha_myisam.cc: Removed some old types storage/myisam/ha_myisam.h: Removed some old types storage/myisam/mi_cache.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/mi_check.c: Removed some old types storage/myisam/mi_checksum.c: Removed some old types storage/myisam/mi_close.c: Removed some old types storage/myisam/mi_create.c: Removed some old types storage/myisam/mi_delete.c: Removed some old types storage/myisam/mi_delete_all.c: Removed some old types storage/myisam/mi_dynrec.c: Removed some old types storage/myisam/mi_extra.c: Removed some old types storage/myisam/mi_key.c: Removed some old types storage/myisam/mi_locking.c: Removed some old types storage/myisam/mi_log.c: Removed some old types storage/myisam/mi_open.c: Removed some old types Removed some not needed casts Check argument of my_write()/my_pwrite() in functions returning int Added casting of string lengths to size_t storage/myisam/mi_packrec.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/mi_page.c: Removed some old types storage/myisam/mi_preload.c: Removed some old types storage/myisam/mi_range.c: Removed some old types storage/myisam/mi_rfirst.c: Removed some old types storage/myisam/mi_rkey.c: Removed some old types storage/myisam/mi_rlast.c: Removed some old types storage/myisam/mi_rnext.c: Removed some old types storage/myisam/mi_rnext_same.c: Removed some old types storage/myisam/mi_rprev.c: Removed some old types storage/myisam/mi_rrnd.c: Removed some old types storage/myisam/mi_rsame.c: Removed some old types storage/myisam/mi_rsamepos.c: Removed some old types storage/myisam/mi_scan.c: Removed some old types storage/myisam/mi_search.c: Removed some old types storage/myisam/mi_static.c: Removed some old types storage/myisam/mi_statrec.c: Removed some old types storage/myisam/mi_test1.c: Removed some old types storage/myisam/mi_test2.c: Removed some old types storage/myisam/mi_test3.c: Removed some old types storage/myisam/mi_unique.c: Removed some old types storage/myisam/mi_update.c: Removed some old types storage/myisam/mi_write.c: Removed some old types storage/myisam/myisam_ftdump.c: Removed some old types storage/myisam/myisamchk.c: Removed some old types storage/myisam/myisamdef.h: Removed some old types storage/myisam/myisamlog.c: Removed some old types Indentation fix storage/myisam/myisampack.c: Removed some old types storage/myisam/rt_index.c: Removed some old types storage/myisam/rt_split.c: Removed some old types storage/myisam/sort.c: Removed some old types storage/myisam/sp_defs.h: Removed some old types storage/myisam/sp_key.c: Removed some old types storage/myisammrg/ha_myisammrg.cc: Removed some old types storage/myisammrg/ha_myisammrg.h: Removed some old types storage/myisammrg/myrg_close.c: Removed some old types storage/myisammrg/myrg_def.h: Removed some old types storage/myisammrg/myrg_delete.c: Removed some old types storage/myisammrg/myrg_open.c: Removed some old types Updated parameters to dirname_part() storage/myisammrg/myrg_queue.c: Removed some old types storage/myisammrg/myrg_rfirst.c: Removed some old types storage/myisammrg/myrg_rkey.c: Removed some old types storage/myisammrg/myrg_rlast.c: Removed some old types storage/myisammrg/myrg_rnext.c: Removed some old types storage/myisammrg/myrg_rnext_same.c: Removed some old types storage/myisammrg/myrg_rprev.c: Removed some old types storage/myisammrg/myrg_rrnd.c: Removed some old types storage/myisammrg/myrg_rsame.c: Removed some old types storage/myisammrg/myrg_update.c: Removed some old types storage/myisammrg/myrg_write.c: Removed some old types storage/ndb/include/util/ndb_opts.h: Removed some old types storage/ndb/src/cw/cpcd/main.cpp: Removed some old types storage/ndb/src/kernel/vm/Configuration.cpp: Removed some old types storage/ndb/src/mgmclient/main.cpp: Removed some old types storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Removed some old types Removed old disabled code storage/ndb/src/mgmsrv/main.cpp: Removed some old types storage/ndb/src/ndbapi/NdbBlob.cpp: Removed some old types storage/ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variable storage/ndb/src/ndbapi/NdbOperationInt.cpp: Added required casts storage/ndb/src/ndbapi/NdbScanOperation.cpp: Added required casts storage/ndb/tools/delete_all.cpp: Removed some old types storage/ndb/tools/desc.cpp: Removed some old types storage/ndb/tools/drop_index.cpp: Removed some old types storage/ndb/tools/drop_tab.cpp: Removed some old types storage/ndb/tools/listTables.cpp: Removed some old types storage/ndb/tools/ndb_config.cpp: Removed some old types storage/ndb/tools/restore/consumer_restore.cpp: Changed some buffers to be uchar* to avoid casts with new defintion of packfrm() storage/ndb/tools/restore/restore_main.cpp: Removed some old types storage/ndb/tools/select_all.cpp: Removed some old types storage/ndb/tools/select_count.cpp: Removed some old types storage/ndb/tools/waiter.cpp: Removed some old types strings/bchange.c: Changed function to use uchar * and size_t strings/bcmp.c: Changed function to use uchar * and size_t strings/bmove512.c: Changed function to use uchar * and size_t strings/bmove_upp.c: Changed function to use uchar * and size_t strings/ctype-big5.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-bin.c: Changed functions to use size_t strings/ctype-cp932.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-czech.c: Fixed indentation Changed functions to use size_t strings/ctype-euc_kr.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-eucjpms.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-gb2312.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-gbk.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-latin1.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-mb.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-simple.c: Changed functions to use size_t Simpler loops for caseup/casedown unsigned int -> uint unsigned char -> uchar strings/ctype-sjis.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-tis620.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-uca.c: Changed functions to use size_t unsigned char -> uchar strings/ctype-ucs2.c: Moved inclusion of stdarg.h to other includes usigned char -> uchar Changed functions to use size_t Changed character length functions to return uint strings/ctype-ujis.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-utf8.c: Changed functions to use size_t unsigned char -> uchar Indentation fixes strings/ctype-win1250ch.c: Indentation fixes Changed functions to use size_t strings/ctype.c: Changed functions to use size_t strings/decimal.c: Changed type for memory argument to uchar * strings/do_ctype.c: Indentation fixes strings/my_strtoll10.c: unsigned char -> uchar strings/my_vsnprintf.c: Changed functions to use size_t strings/r_strinstr.c: Removed some old types Changed functions to use size_t strings/str_test.c: Removed some old types strings/strappend.c: Changed functions to use size_t strings/strcont.c: Removed some old types strings/strfill.c: Removed some old types strings/strinstr.c: Changed functions to use size_t strings/strlen.c: Changed functions to use size_t strings/strmake.c: Changed functions to use size_t strings/strnlen.c: Changed functions to use size_t strings/strnmov.c: Changed functions to use size_t strings/strto.c: unsigned char -> uchar strings/strtod.c: Changed functions to use size_t strings/strxnmov.c: Changed functions to use size_t strings/xml.c: Changed functions to use size_t Indentation fixes tests/mysql_client_test.c: Removed some old types tests/thread_test.c: Removed some old types vio/test-ssl.c: Removed some old types vio/test-sslclient.c: Removed some old types vio/test-sslserver.c: Removed some old types vio/vio.c: Removed some old types vio/vio_priv.h: Removed some old types Changed vio_read()/vio_write() to work with size_t vio/viosocket.c: Changed vio_read()/vio_write() to work with size_t Indentation fixes vio/viossl.c: Changed vio_read()/vio_write() to work with size_t Indentation fixes vio/viosslfactories.c: Removed some old types vio/viotest-ssl.c: Removed some old types win/README: More explanations
2007-05-10 11:59:39 +02:00
uchar *argument)
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes Changes that requires code changes in other code of other storage engines. (Note that all changes are very straightforward and one should find all issues by compiling a --debug build and fixing all compiler errors and all asserts in field.cc while running the test suite), - New optional handler function introduced: reset() This is called after every DML statement to make it easy for a handler to statement specific cleanups. (The only case it's not called is if force the file to be closed) - handler::extra(HA_EXTRA_RESET) is removed. Code that was there before should be moved to handler::reset() - table->read_set contains a bitmap over all columns that are needed in the query. read_row() and similar functions only needs to read these columns - table->write_set contains a bitmap over all columns that will be updated in the query. write_row() and update_row() only needs to update these columns. The above bitmaps should now be up to date in all context (including ALTER TABLE, filesort()). The handler is informed of any changes to the bitmap after fix_fields() by calling the virtual function handler::column_bitmaps_signal(). If the handler does caching of these bitmaps (instead of using table->read_set, table->write_set), it should redo the caching in this code. as the signal() may be sent several times, it's probably best to set a variable in the signal and redo the caching on read_row() / write_row() if the variable was set. - Removed the read_set and write_set bitmap objects from the handler class - Removed all column bit handling functions from the handler class. (Now one instead uses the normal bitmap functions in my_bitmap.c instead of handler dedicated bitmap functions) - field->query_id is removed. One should instead instead check table->read_set and table->write_set if a field is used in the query. - handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now instead use table->read_set to check for which columns to retrieve. - If a handler needs to call Field->val() or Field->store() on columns that are not used in the query, one should install a temporary all-columns-used map while doing so. For this, we provide the following functions: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); field->val(); dbug_tmp_restore_column_map(table->read_set, old_map); and similar for the write map: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); field->val(); dbug_tmp_restore_column_map(table->write_set, old_map); If this is not done, you will sooner or later hit a DBUG_ASSERT in the field store() / val() functions. (For not DBUG binaries, the dbug_tmp_restore_column_map() and dbug_tmp_restore_column_map() are inline dummy functions and should be optimized away be the compiler). - If one needs to temporary set the column map for all binaries (and not just to avoid the DBUG_ASSERT() in the Field::store() / Field::val() methods) one should use the functions tmp_use_all_columns() and tmp_restore_column_map() instead of the above dbug_ variants. - All 'status' fields in the handler base class (like records, data_file_length etc) are now stored in a 'stats' struct. This makes it easier to know what status variables are provided by the base handler. This requires some trivial variable names in the extra() function. - New virtual function handler::records(). This is called to optimize COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true. (stats.records is not supposed to be an exact value. It's only has to be 'reasonable enough' for the optimizer to be able to choose a good optimization path). - Non virtual handler::init() function added for caching of virtual constants from engine. - Removed has_transactions() virtual method. Now one should instead return HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support transactions. - The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument that is to be used with 'new handler_name()' to allocate the handler in the right area. The xxxx_create_handler() function is also responsible for any initialization of the object before returning. For example, one should change: static handler *myisam_create_handler(TABLE_SHARE *table) { return new ha_myisam(table); } -> static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { return new (mem_root) ha_myisam(table); } - New optional virtual function: use_hidden_primary_key(). This is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined but we don't have a primary key. This allows the handler to take precisions in remembering any hidden primary key to able to update/delete any found row. The default handler marks all columns to be read. - handler::table_flags() now returns a ulonglong (to allow for more flags). - New/changed table_flags() - HA_HAS_RECORDS Set if ::records() is supported - HA_NO_TRANSACTIONS Set if engine doesn't support transactions - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE Set if we should mark all primary key columns for read when reading rows as part of a DELETE statement. If there is no primary key, all columns are marked for read. - HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some cases (based on table->read_set) - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - HA_DUPP_POS Renamed to HA_DUPLICATE_POS - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE Set this if we should mark ALL key columns for read when when reading rows as part of a DELETE statement. In case of an update we will mark all keys for read for which key part changed value. - HA_STATS_RECORDS_IS_EXACT Set this if stats.records is exact. (This saves us some extra records() calls when optimizing COUNT(*)) - Removed table_flags() - HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if handler::records() gives an exact count() and HA_STATS_RECORDS_IS_EXACT if stats.records is exact. - HA_READ_RND_SAME Removed (no one supported this one) - Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk() - Renamed handler::dupp_pos to handler::dup_pos - Removed not used variable handler::sortkey Upper level handler changes: - ha_reset() now does some overall checks and calls ::reset() - ha_table_flags() added. This is a cached version of table_flags(). The cache is updated on engine creation time and updated on open. MySQL level changes (not obvious from the above): - DBUG_ASSERT() added to check that column usage matches what is set in the column usage bit maps. (This found a LOT of bugs in current column marking code). - In 5.1 before, all used columns was marked in read_set and only updated columns was marked in write_set. Now we only mark columns for which we need a value in read_set. - Column bitmaps are created in open_binary_frm() and open_table_from_share(). (Before this was in table.cc) - handler::table_flags() calls are replaced with handler::ha_table_flags() - For calling field->val() you must have the corresponding bit set in table->read_set. For calling field->store() you must have the corresponding bit set in table->write_set. (There are asserts in all store()/val() functions to catch wrong usage) - thd->set_query_id is renamed to thd->mark_used_columns and instead of setting this to an integer value, this has now the values: MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE Changed also all variables named 'set_query_id' to mark_used_columns. - In filesort() we now inform the handler of exactly which columns are needed doing the sort and choosing the rows. - The TABLE_SHARE object has a 'all_set' column bitmap one can use when one needs a column bitmap with all columns set. (This is used for table->use_all_columns() and other places) - The TABLE object has 3 column bitmaps: - def_read_set Default bitmap for columns to be read - def_write_set Default bitmap for columns to be written - tmp_set Can be used as a temporary bitmap when needed. The table object has also two pointer to bitmaps read_set and write_set that the handler should use to find out which columns are used in which way. - count() optimization now calls handler::records() instead of using handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true). - Added extra argument to Item::walk() to indicate if we should also traverse sub queries. - Added TABLE parameter to cp_buffer_from_ref() - Don't close tables created with CREATE ... SELECT but keep them in the table cache. (Faster usage of newly created tables). New interfaces: - table->clear_column_bitmaps() to initialize the bitmaps for tables at start of new statements. - table->column_bitmaps_set() to set up new column bitmaps and signal the handler about this. - table->column_bitmaps_set_no_signal() for some few cases where we need to setup new column bitmaps but don't signal the handler (as the handler has already been signaled about these before). Used for the momement only in opt_range.cc when doing ROR scans. - table->use_all_columns() to install a bitmap where all columns are marked as use in the read and the write set. - table->default_column_bitmaps() to install the normal read and write column bitmaps, but not signaling the handler about this. This is mainly used when creating TABLE instances. - table->mark_columns_needed_for_delete(), table->mark_columns_needed_for_delete() and table->mark_columns_needed_for_insert() to allow us to put additional columns in column usage maps if handler so requires. (The handler indicates what it neads in handler->table_flags()) - table->prepare_for_position() to allow us to tell handler that it needs to read primary key parts to be able to store them in future table->position() calls. (This replaces the table->file->ha_retrieve_all_pk function) - table->mark_auto_increment_column() to tell handler are going to update columns part of any auto_increment key. - table->mark_columns_used_by_index() to mark all columns that is part of an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow it to quickly know that it only needs to read colums that are part of the key. (The handler can also use the column map for detecting this, but simpler/faster handler can just monitor the extra() call). - table->mark_columns_used_by_index_no_reset() to in addition to other columns, also mark all columns that is used by the given key. - table->restore_column_maps_after_mark_index() to restore to default column maps after a call to table->mark_columns_used_by_index(). - New item function register_field_in_read_map(), for marking used columns in table->read_map. Used by filesort() to mark all used columns - Maintain in TABLE->merge_keys set of all keys that are used in query. (Simplices some optimization loops) - Maintain Field->part_of_key_not_clustered which is like Field->part_of_key but the field in the clustered key is not assumed to be part of all index. (used in opt_range.cc for faster loops) - dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map() tmp_use_all_columns() and tmp_restore_column_map() functions to temporally mark all columns as usable. The 'dbug_' version is primarily intended inside a handler when it wants to just call Field:store() & Field::val() functions, but don't need the column maps set for any other usage. (ie:: bitmap_is_set() is never called) - We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set. The reason for this is that if we have a column marked only for write we can't in the MySQL level know if the value changed or not. The reason this worked before was that MySQL marked all to be written columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden bug'. - open_table_from_share() does not anymore setup temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler(). (Simpler, faster code) Bugs fixed: - Column marking was not done correctly in a lot of cases. (ALTER TABLE, when using triggers, auto_increment fields etc) (Could potentially result in wrong values inserted in table handlers relying on that the old column maps or field->set_query_id was correct) Especially when it comes to triggers, there may be cases where the old code would cause lost/wrong values for NDB and/or InnoDB tables. - Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags: OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG. This allowed me to remove some wrong warnings about: "Some non-transactional changed tables couldn't be rolled back" - Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose some warnings about "Some non-transactional changed tables couldn't be rolled back") - Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table() which could cause delete_table to report random failures. - Fixed core dumps for some tests when running with --debug - Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) - slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. - If we get an duplicate row on insert, change column map to read and write all columns while retrying the operation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. - For table handler that doesn't support NULL in keys, we would give an error when creating a primary key with NULL fields, even after the fields has been automaticly converted to NOT NULL. - Creating a primary key on a SPATIAL key, would fail if field was not declared as NOT NULL. Cleanups: - Removed not used condition argument to setup_tables - Removed not needed item function reset_query_id_processor(). - Field->add_index is removed. Now this is instead maintained in (field->flags & FIELD_IN_ADD_INDEX) - Field->fieldnr is removed (use field->field_index instead) - New argument to filesort() to indicate that it should return a set of row pointers (not used columns). This allowed me to remove some references to sql_command in filesort and should also enable us to return column results in some cases where we couldn't before. - Changed column bitmap handling in opt_range.cc to be aligned with TABLE bitmap, which allowed me to use bitmap functions instead of looping over all fields to create some needed bitmaps. (Faster and smaller code) - Broke up found too long lines - Moved some variable declaration at start of function for better code readability. - Removed some not used arguments from functions. (setup_fields(), mysql_prepare_insert_check_table()) - setup_fields() now takes an enum instead of an int for marking columns usage. - For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. - Changed some constants to enum's and define's. - Using separate column read and write sets allows for easier checking of timestamp field was set by statement. - Remove calls to free_io_cache() as this is now done automaticly in ha_reset() - Don't build table->normalized_path as this is now identical to table->path (after bar's fixes to convert filenames) - Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to do comparision with the 'convert-dbug-for-diff' tool. Things left to do in 5.1: - We wrongly log failed CREATE TABLE ... SELECT in some cases when using row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result) Mats has promised to look into this. - Test that my fix for CREATE TABLE ... SELECT is indeed correct. (I added several test cases for this, but in this case it's better that someone else also tests this throughly). Lars has promosed to do this. BitKeeper/etc/ignore: added mysys/test_bitmap include/base64.h: Removed my_global.h, as this must be included first in any program include/heap.h: Added heap_reset() (Required by new handler interface) include/my_base.h: Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET). HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary include/my_bitmap.h: Remove my_pthread.h (should be included at upper level) Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp() Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void include/myisam.h: Added mi_reset() (Required by new handler interface) include/myisammrg.h: Added myrg_reset() (Required by new handler interface) include/mysql_com.h: Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/install_test_db.sh: Simplify ldata usage Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set) mysql-test/mysql-test-run.pl: Added --tmpdir=. to bootstrap mysql-test/mysql-test-run.sh: Use copy instead of INSTALL_DB for master and slave databases. (Speeds up startup time a lot!) Remove snapshot directories at startup (removes some strange warnings) mysql-test/r/binlog_row_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/r/binlog_stm_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment mysql-test/r/create.result: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/r/federated.result: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/r/func_gconcat.result: Enable some disabled tests (converted them slightly to be predictable) mysql-test/r/func_time.result: Added drop of test function mysql-test/r/innodb_mysql.result: Added tests for CREATE ... SELECT mysql-test/r/insert.result: More tests Added testing of duplicate columns in insert mysql-test/r/loaddata.result: Added testing LOAD DATA ... SET ... mysql-test/r/multi_update.result: Test multi updates and deletes using primary key and without mysql-test/r/ndb_index_unique.result: Better error message mysql-test/r/ndb_replace.result: New correct result after fixing REPLACE handling with NDB mysql-test/r/rpl_ddl.result: Now we don't get these (wrong) warnings anymore mysql-test/r/view_grant.result: Drop used views mysql-test/t/create.test: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/t/federated.test: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/t/func_gconcat.test: Enable some disabled tests (converted them slightly to be predictable) mysql-test/t/func_time.test: Added drop of test function mysql-test/t/innodb_mysql.test: Added tests for CREATE ... SELECT mysql-test/t/insert.test: More tests Added testing of duplicate columns in insert mysql-test/t/loaddata.test: Added testing LOAD DATA ... SET ... mysql-test/t/multi_update.test: Test multi updates and deletes using primary key and without mysql-test/t/view_grant.test: Drop used views mysql-test/valgrind.supp: Added supression of not needed warnings when printing stack trace mysys/base64.c: Include my_global.h first mysys/my_bitmap.c: Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy() Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström) Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed. Changed how mutex is allocated to make 'bitmap_free()' function simpler. mysys/thr_lock.c: Added 0x before thread pointers (for easier comparison of DBUG traces) sql/event.cc: Ensure 'use_all_columns()' is used for event tables Don't print warning that event table is damaged if it doesn't exists. sql/field.cc: Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set (Rest of changes are only indentation cleanups) sql/field.h: Removed Field->query_id (replaced by table->read_set and table->write_set) Removed Field->fieldnr (use Field->field_index instead) Removed Field->add_index (Use Field->flags instead) Add Field->part_of_key_not_clustered (for usage in opt_range.cc) sql/filesort.cc: Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set. This allowed me to remove checking of sql_command. Create a temporary column bitmap for fields that are used by the sorting process. Use column bitmaps instead of query_id sql/ha_berkeley.cc: Update to 'newer' table handler interface sql/ha_berkeley.h: Update to 'newer' table handler interface sql/ha_federated.cc: Update to 'newer' table handler interface Only read columns that are needed from remote server. In case of eq ranges, don't generate two conditions in the WHERE clause (this can still be optimized, but would require a bigger code change) Use 'simpler to use' XXXX_LEN' macros A bit simpler logic in ::write_row() when creating statements. In update, only include test of fields actually read. (This greatly simplifies the queries sent by the federated engine) Similar changes done for delete_row() sql/ha_federated.h: Update to 'newer' table handler interface Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE sql/ha_heap.cc: Update to 'newer' table handler interface sql/ha_heap.h: Update to 'newer' table handler interface sql/ha_innodb.cc: Update to 'newer' table handler interface - Update innobase_create_handler() to new interface - Removed HA_NOT_EXACT_COUNT (not needed) - Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - Prefixed base status variables with 'stats' - Use table column bitmaps instead of ha_get_bit_in_read_set() - Added ::reset(), with code from ::extra(HA_EXTRA_RESET) - Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as the table->read_set and table->write_set bitmaps now are accurate sql/ha_innodb.h: Update to 'newer' table handler interface - table_flags are now ulonglong - Added reset() method - Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns. - Made build_template() a class function to be able to easier access class variables sql/ha_myisam.cc: Update to 'newer' table handler interface sql/ha_myisam.h: Update to 'newer' table handler interface sql/ha_myisammrg.cc: Update to 'newer' table handler interface sql/ha_myisammrg.h: Update to 'newer' table handler interface sql/ha_ndbcluster.cc: Update to 'newer' table handler interface Fixed use_blob_value() to be accurate In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map Correct dumping of field data with DBUG_DUMP Prefix addresses in DBUG_PRINT with 0x Fixed usage of not initialized memory Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index. sql/ha_ndbcluster.h: Update to 'newer' table handler interface sql/ha_ndbcluster_binlog.cc: Mark usage of all columns in ndbcluster binlog tables false -> FALSE, true -> TRUE Use table->s->all_set instead of creating a temporary bitmap. sql/ha_partition.cc: Update to 'newer' table handler interface Added memroot to initialise_partitions() and related functions to get faster memory allocation. partition_create_handler() is now responsible for initialisation of the partition object Some trivial optimizations and indentation fixes Ensure that table_flags() are up to date Removed documentation for removed HA_EXTRA flags Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance' sql/ha_partition.h: Update to 'newer' table handler interface sql/handler.cc: create_xxx handler now takes MEMROOT as an argument to simplify memory allocation. Much simpler get_new_handler() (Initialization of the object is now handled by the create method for the engine) Moved all allocation of bitmap handling to the TABLE object (in table.cc) Added column_bitmaps_signal() to signal column usage changes. Changed binlog_log_row() to use the exiusting all_set bitmap in the table object. Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset() Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row sql/handler.h: Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME HA_DUPP_POS -> HA_DUPLICATE_POS HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records() HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION Added future row type 'ROW_TYPE_PAGES' Added MEM_ROOT to handlerton 'create' function Added ha_statistics, a structure for all status variable in the base handler class. Moved all status variables in the handler class into a stats structs to improve readability. ha_table_flags() is now a cached (not virtual) version of table_flags() reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own. Renamed dupp_ref to dup_ref Renamed not used handler::sortkey Moved read_set and write_set to TABLE structure handler::init() function added for cacheing of virtual constants from engine. sql/item.cc: Added register_field_in_read_map() for marking used columns in expression. This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting. Initalize value.cs_info.character_set_client to fix core dump bug with --debug set_query_id -> mark_used_columns Mark used columns in read_set OR write_set. sql/item.h: Removed reset_query_id_processor() as it's not needed anymore. Added register_field_in_read_map() Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_cmpfunc.cc: Temporary mark used columns to be read/writable Update Item::walk to new interface sql/item_cmpfunc.h: Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_func.cc: Update Item::walk() to new interface table_flags() -> ha_table_flags() sql/item_func.h: Update Item::walk() to new interface sql/item_row.cc: Update Item::walk() to new interface sql/item_row.h: Update Item::walk() to new interface sql/item_strfunc.h: Update Item::walk() to new interface sql/item_subselect.cc: Added Item_subselect::walk() (It was a bug it was missing before. Not sure what kind of bugs this could have caused) sql/item_subselect.h: Update Item::walk() to new interface sql/item_sum.cc: Update Item::walk() to new interface Updates for new handler interace sql/item_sum.h: Update Item::walk() to new interface sql/key.cc: Updates for new handler interace sql/log.cc: Mark all columns used for log tables Split options flag Ensured that second argument to trans_register_ha is a bool sql/log_event.cc: Fixed comments to be withing 79 characters Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings Updates for new handler interface Use 0x%lx instead of %p (portability problem) sql/mysql_priv.h: Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback Removed not used 'conds' argument to setup_tables sql/mysqld.cc: Indentation fixes and removed old comment sql/opt_range.cc: Update to new handler and bitmap interface. Fixed calls to cp_buffer_from_ref() and walk() (new argument). Create new temporary bitmaps for ror scans. (Needed because of handler changes and to get more accurate column bitmaps than before) Remove not needed file->ha_reset() call before file->close(). Some trivial optimization and indentation fixes. Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts. Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record. This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling. (This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans) Optimized bitmap handling in ror scans: - Start bitmap at position 0, not 1 - Use same bitmap size as in TABLE - Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table sql/opt_range.h: Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan Added temporary column bitmaps used in ROR scans sql/opt_sum.cc: Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set. sql/protocol.cc: We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user sql/records.cc: Updates for new handler interface sql/set_var.cc: Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags sql/share/errmsg.txt: Fixed wrong sql/sp.cc: Mark that we are using all columns for the proc table Update call to setup_tables() to use new prototype sql/sp_head.cc: Removed QQ comment sql/spatial.cc: Removed wrong QQ comment sql/sql_acl.cc: Mark that we need all columns for acl tables Supply memroot to some 'new' calls. Indentation fixes sql/sql_base.cc: set_query_id removed Ensure we call ha_reset() at end of each statement Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set) Fixed marking of some columns that was not proplerly marked before Maintain in TABLE->merge_keys set of all keys that are used in some way Removed not used 'conds' argument from setup_tables() Remove not used setting of 'dupp_field' in insert_fields() Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) sql/sql_bitmap.h: Added is_overlapping() sql/sql_class.cc: Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. set_query_id -> mark_used_columns Simpler variable usage in pack_row() (cleanup) Moved some variable declartion at start of function for better code readability sql/sql_class.h: Added enum_mark_columns Updated comments Renamed dupp_field -> dup_field Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE. (This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables) sql/sql_delete.cc: Updates to new handler interface Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires. Call table->prepare_for_position() to tell handler that we are going to call ha_position(). Removed call to free_io_cache(). (io_cache is now removed in ha_reset()). Fixed calls to setup_tables() sql/sql_do.cc: Update call to setup_fields() sql/sql_handler.cc: Tell handler tables to always read all columns. Use temporary column map when storing value in field for later index usage sql/sql_help.cc: Makr all used fields to be read Update call to setup_fields() sql/sql_insert.cc: Tell handler we are going to update the auto_increment column dupp_field -> dup_field Set column usage bits for timestamp field. Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column() Removed not used argument from mysql_prepare_insert_check_table(). If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. Setup new bitmaps for delayed insert rows Remove reseting of next_number_fields as it will be reset on next call to handler_insert() Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE. The issue was that one should not to reset this flag as it may be set by a previous statement. The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional. I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done) Don't close tables created with CREATE ... SELECT but keep them in the table cache. Moved out MY_HOOKS from inside function (better readability) sql/sql_load.cc: Update to use new handler and column marking interface Update using setup_tables() sql/sql_olap.cc: Update calls to setup_tables Use enums instead of constants to setup_fields() sql/sql_parse.cc: Handle OPTION_KEEP_LOG: - Set it on CREATE TEMPORARY TABLE / DROP TABLE - Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset - Don't set it for CREATE ... SELECT (this is handled in select_create class) Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset. If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands sql/sql_partition.cc: Update walk() usage Trivial indentation fixes sql/sql_plugin.cc: Mark all columns as used for plugins sql/sql_prepare.cc: Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly) Updates for new handler interface Update calls to setup_fields() sql/sql_repl.cc: Indentation fixes sql/sql_select.cc: Update call to setup_tables() and setup_fields() Remove some old disabled code Update to new hadler interface Indentation cleanups Added column bitmaps for temporary tables. Remove updating of the removed slots in the Field class Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps) For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. sql/sql_select.h: Indentaition fixes. Install temporary column usage maps when needed Added TABLE element to cp_buffer_from_ref() sql/sql_show.cc: Update to new handler interface Mark all columns used for internal tables. Style fixes. Added support for 'future' ROW_TYPE_PAGES. Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly. sql/sql_table.cc: Update to new handler interface Simple my_snprintf -> strmake() Changed some constants to defines Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL) Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX Mark all columns as used for ALTER TABLE Style fixes Update call to filesort() sql/sql_trigger.h: Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in. sql/sql_udf.cc: Mark all columns as used for udf system table. sql/sql_union.cc: Update call to walk() Update to new handler interface sql/sql_update.cc: Remove query_id argument from compare_record() Use column bitmaps instead of query_id. We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value. Update call to setup_fields() Using separate column read and write sets allows for easier checking of timestamp field was set by statement. Removed call to free_io_cache() as this is now done in ha_reset() Call table->mark_columns_needed_for_update() and table->prepare_for_position() Style fixes sql/sql_view.cc: Style fixes sql/table.cc: Remove implicitely include 'errno.h' Remove code for building normalized path, as this is now identical to 'path' Remove field->fieldnr Added update of field->part_of_key_not_clustered() Create column bitmaps in TABLE and TABLE_SHARE Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler() Update to new handler interface Update call to walk() Added new functions: - st_table::clear_column_bitmaps() - st_table::prepare_for_position() - st_table::mark_columns_used_by_index() - st_table::restore_column_maps_after_mark_index() - st_table::mark_columns_used_by_index_no_reset() - st_table::mark_auto_increment_column() - st_table::mark_columns_needed_for_delete() - st_table::mark_columns_needed_for_update() - st_table::mark_columns_needed_for_insert() sql/table.h: Moved column usage bitmaps from handler to TABLE Added to TABLE_SHARE all_set and column_bitmap_size Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set. Declared all new table column bitmap functions Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps() Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val(). sql/tztime.cc: Mark all columns as used for timezone tables storage/archive/ha_archive.cc: Update to new handler interface storage/archive/ha_archive.h: Update to new handler interface storage/blackhole/ha_blackhole.cc: Update to new handler interface storage/blackhole/ha_blackhole.h: Update to new handler interface removed not needed flag HA_DUPP_POS storage/csv/ha_tina.cc: Update to new handler interface storage/csv/ha_tina.h: Update to new handler interface storage/example/ha_example.cc: Update to new handler interface storage/example/ha_example.h: Update to new handler interface storage/heap/hp_extra.c: Added heap_reset() (Required by new handler interface) storage/heap/hp_test2.c: Use heap_reset() storage/myisam/ft_boolean_search.c: Fixed compiler warning storage/myisam/mi_extra.c: Added mi_reset() (Required by new handler interface) storage/myisam/mi_search.c: Fixed DBUG_PRINT messages to use 0x%lx instead of %lx storage/myisam/mi_test2.c: Use mi_reset() storage/myisam/myisampack.c: Use mi_reset() storage/myisammrg/myrg_extra.c: Added myrg_reset() (Required by new handler interface) unittest/mysys/base64.t.c: Include my_global.h Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
{
if (!(unit->uncacheable & ~UNCACHEABLE_DEPENDENT) && engine->is_executed() &&
!unit->describe)
{
/*
The subquery has already been executed (for real, it wasn't EXPLAIN's
fake execution) so it should not matter what it has inside.
The actual reason for not walking inside is that parts of the subquery
(e.g. JTBM join nests and their IN-equality conditions may have been
invalidated by irreversible cleanups (those happen after an uncorrelated
subquery has been executed).
*/
return (this->*processor)(argument);
}
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes Changes that requires code changes in other code of other storage engines. (Note that all changes are very straightforward and one should find all issues by compiling a --debug build and fixing all compiler errors and all asserts in field.cc while running the test suite), - New optional handler function introduced: reset() This is called after every DML statement to make it easy for a handler to statement specific cleanups. (The only case it's not called is if force the file to be closed) - handler::extra(HA_EXTRA_RESET) is removed. Code that was there before should be moved to handler::reset() - table->read_set contains a bitmap over all columns that are needed in the query. read_row() and similar functions only needs to read these columns - table->write_set contains a bitmap over all columns that will be updated in the query. write_row() and update_row() only needs to update these columns. The above bitmaps should now be up to date in all context (including ALTER TABLE, filesort()). The handler is informed of any changes to the bitmap after fix_fields() by calling the virtual function handler::column_bitmaps_signal(). If the handler does caching of these bitmaps (instead of using table->read_set, table->write_set), it should redo the caching in this code. as the signal() may be sent several times, it's probably best to set a variable in the signal and redo the caching on read_row() / write_row() if the variable was set. - Removed the read_set and write_set bitmap objects from the handler class - Removed all column bit handling functions from the handler class. (Now one instead uses the normal bitmap functions in my_bitmap.c instead of handler dedicated bitmap functions) - field->query_id is removed. One should instead instead check table->read_set and table->write_set if a field is used in the query. - handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now instead use table->read_set to check for which columns to retrieve. - If a handler needs to call Field->val() or Field->store() on columns that are not used in the query, one should install a temporary all-columns-used map while doing so. For this, we provide the following functions: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); field->val(); dbug_tmp_restore_column_map(table->read_set, old_map); and similar for the write map: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); field->val(); dbug_tmp_restore_column_map(table->write_set, old_map); If this is not done, you will sooner or later hit a DBUG_ASSERT in the field store() / val() functions. (For not DBUG binaries, the dbug_tmp_restore_column_map() and dbug_tmp_restore_column_map() are inline dummy functions and should be optimized away be the compiler). - If one needs to temporary set the column map for all binaries (and not just to avoid the DBUG_ASSERT() in the Field::store() / Field::val() methods) one should use the functions tmp_use_all_columns() and tmp_restore_column_map() instead of the above dbug_ variants. - All 'status' fields in the handler base class (like records, data_file_length etc) are now stored in a 'stats' struct. This makes it easier to know what status variables are provided by the base handler. This requires some trivial variable names in the extra() function. - New virtual function handler::records(). This is called to optimize COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true. (stats.records is not supposed to be an exact value. It's only has to be 'reasonable enough' for the optimizer to be able to choose a good optimization path). - Non virtual handler::init() function added for caching of virtual constants from engine. - Removed has_transactions() virtual method. Now one should instead return HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support transactions. - The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument that is to be used with 'new handler_name()' to allocate the handler in the right area. The xxxx_create_handler() function is also responsible for any initialization of the object before returning. For example, one should change: static handler *myisam_create_handler(TABLE_SHARE *table) { return new ha_myisam(table); } -> static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { return new (mem_root) ha_myisam(table); } - New optional virtual function: use_hidden_primary_key(). This is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined but we don't have a primary key. This allows the handler to take precisions in remembering any hidden primary key to able to update/delete any found row. The default handler marks all columns to be read. - handler::table_flags() now returns a ulonglong (to allow for more flags). - New/changed table_flags() - HA_HAS_RECORDS Set if ::records() is supported - HA_NO_TRANSACTIONS Set if engine doesn't support transactions - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE Set if we should mark all primary key columns for read when reading rows as part of a DELETE statement. If there is no primary key, all columns are marked for read. - HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some cases (based on table->read_set) - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - HA_DUPP_POS Renamed to HA_DUPLICATE_POS - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE Set this if we should mark ALL key columns for read when when reading rows as part of a DELETE statement. In case of an update we will mark all keys for read for which key part changed value. - HA_STATS_RECORDS_IS_EXACT Set this if stats.records is exact. (This saves us some extra records() calls when optimizing COUNT(*)) - Removed table_flags() - HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if handler::records() gives an exact count() and HA_STATS_RECORDS_IS_EXACT if stats.records is exact. - HA_READ_RND_SAME Removed (no one supported this one) - Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk() - Renamed handler::dupp_pos to handler::dup_pos - Removed not used variable handler::sortkey Upper level handler changes: - ha_reset() now does some overall checks and calls ::reset() - ha_table_flags() added. This is a cached version of table_flags(). The cache is updated on engine creation time and updated on open. MySQL level changes (not obvious from the above): - DBUG_ASSERT() added to check that column usage matches what is set in the column usage bit maps. (This found a LOT of bugs in current column marking code). - In 5.1 before, all used columns was marked in read_set and only updated columns was marked in write_set. Now we only mark columns for which we need a value in read_set. - Column bitmaps are created in open_binary_frm() and open_table_from_share(). (Before this was in table.cc) - handler::table_flags() calls are replaced with handler::ha_table_flags() - For calling field->val() you must have the corresponding bit set in table->read_set. For calling field->store() you must have the corresponding bit set in table->write_set. (There are asserts in all store()/val() functions to catch wrong usage) - thd->set_query_id is renamed to thd->mark_used_columns and instead of setting this to an integer value, this has now the values: MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE Changed also all variables named 'set_query_id' to mark_used_columns. - In filesort() we now inform the handler of exactly which columns are needed doing the sort and choosing the rows. - The TABLE_SHARE object has a 'all_set' column bitmap one can use when one needs a column bitmap with all columns set. (This is used for table->use_all_columns() and other places) - The TABLE object has 3 column bitmaps: - def_read_set Default bitmap for columns to be read - def_write_set Default bitmap for columns to be written - tmp_set Can be used as a temporary bitmap when needed. The table object has also two pointer to bitmaps read_set and write_set that the handler should use to find out which columns are used in which way. - count() optimization now calls handler::records() instead of using handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true). - Added extra argument to Item::walk() to indicate if we should also traverse sub queries. - Added TABLE parameter to cp_buffer_from_ref() - Don't close tables created with CREATE ... SELECT but keep them in the table cache. (Faster usage of newly created tables). New interfaces: - table->clear_column_bitmaps() to initialize the bitmaps for tables at start of new statements. - table->column_bitmaps_set() to set up new column bitmaps and signal the handler about this. - table->column_bitmaps_set_no_signal() for some few cases where we need to setup new column bitmaps but don't signal the handler (as the handler has already been signaled about these before). Used for the momement only in opt_range.cc when doing ROR scans. - table->use_all_columns() to install a bitmap where all columns are marked as use in the read and the write set. - table->default_column_bitmaps() to install the normal read and write column bitmaps, but not signaling the handler about this. This is mainly used when creating TABLE instances. - table->mark_columns_needed_for_delete(), table->mark_columns_needed_for_delete() and table->mark_columns_needed_for_insert() to allow us to put additional columns in column usage maps if handler so requires. (The handler indicates what it neads in handler->table_flags()) - table->prepare_for_position() to allow us to tell handler that it needs to read primary key parts to be able to store them in future table->position() calls. (This replaces the table->file->ha_retrieve_all_pk function) - table->mark_auto_increment_column() to tell handler are going to update columns part of any auto_increment key. - table->mark_columns_used_by_index() to mark all columns that is part of an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow it to quickly know that it only needs to read colums that are part of the key. (The handler can also use the column map for detecting this, but simpler/faster handler can just monitor the extra() call). - table->mark_columns_used_by_index_no_reset() to in addition to other columns, also mark all columns that is used by the given key. - table->restore_column_maps_after_mark_index() to restore to default column maps after a call to table->mark_columns_used_by_index(). - New item function register_field_in_read_map(), for marking used columns in table->read_map. Used by filesort() to mark all used columns - Maintain in TABLE->merge_keys set of all keys that are used in query. (Simplices some optimization loops) - Maintain Field->part_of_key_not_clustered which is like Field->part_of_key but the field in the clustered key is not assumed to be part of all index. (used in opt_range.cc for faster loops) - dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map() tmp_use_all_columns() and tmp_restore_column_map() functions to temporally mark all columns as usable. The 'dbug_' version is primarily intended inside a handler when it wants to just call Field:store() & Field::val() functions, but don't need the column maps set for any other usage. (ie:: bitmap_is_set() is never called) - We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set. The reason for this is that if we have a column marked only for write we can't in the MySQL level know if the value changed or not. The reason this worked before was that MySQL marked all to be written columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden bug'. - open_table_from_share() does not anymore setup temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler(). (Simpler, faster code) Bugs fixed: - Column marking was not done correctly in a lot of cases. (ALTER TABLE, when using triggers, auto_increment fields etc) (Could potentially result in wrong values inserted in table handlers relying on that the old column maps or field->set_query_id was correct) Especially when it comes to triggers, there may be cases where the old code would cause lost/wrong values for NDB and/or InnoDB tables. - Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags: OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG. This allowed me to remove some wrong warnings about: "Some non-transactional changed tables couldn't be rolled back" - Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose some warnings about "Some non-transactional changed tables couldn't be rolled back") - Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table() which could cause delete_table to report random failures. - Fixed core dumps for some tests when running with --debug - Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) - slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. - If we get an duplicate row on insert, change column map to read and write all columns while retrying the operation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. - For table handler that doesn't support NULL in keys, we would give an error when creating a primary key with NULL fields, even after the fields has been automaticly converted to NOT NULL. - Creating a primary key on a SPATIAL key, would fail if field was not declared as NOT NULL. Cleanups: - Removed not used condition argument to setup_tables - Removed not needed item function reset_query_id_processor(). - Field->add_index is removed. Now this is instead maintained in (field->flags & FIELD_IN_ADD_INDEX) - Field->fieldnr is removed (use field->field_index instead) - New argument to filesort() to indicate that it should return a set of row pointers (not used columns). This allowed me to remove some references to sql_command in filesort and should also enable us to return column results in some cases where we couldn't before. - Changed column bitmap handling in opt_range.cc to be aligned with TABLE bitmap, which allowed me to use bitmap functions instead of looping over all fields to create some needed bitmaps. (Faster and smaller code) - Broke up found too long lines - Moved some variable declaration at start of function for better code readability. - Removed some not used arguments from functions. (setup_fields(), mysql_prepare_insert_check_table()) - setup_fields() now takes an enum instead of an int for marking columns usage. - For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. - Changed some constants to enum's and define's. - Using separate column read and write sets allows for easier checking of timestamp field was set by statement. - Remove calls to free_io_cache() as this is now done automaticly in ha_reset() - Don't build table->normalized_path as this is now identical to table->path (after bar's fixes to convert filenames) - Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to do comparision with the 'convert-dbug-for-diff' tool. Things left to do in 5.1: - We wrongly log failed CREATE TABLE ... SELECT in some cases when using row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result) Mats has promised to look into this. - Test that my fix for CREATE TABLE ... SELECT is indeed correct. (I added several test cases for this, but in this case it's better that someone else also tests this throughly). Lars has promosed to do this. BitKeeper/etc/ignore: added mysys/test_bitmap include/base64.h: Removed my_global.h, as this must be included first in any program include/heap.h: Added heap_reset() (Required by new handler interface) include/my_base.h: Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET). HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary include/my_bitmap.h: Remove my_pthread.h (should be included at upper level) Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp() Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void include/myisam.h: Added mi_reset() (Required by new handler interface) include/myisammrg.h: Added myrg_reset() (Required by new handler interface) include/mysql_com.h: Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/install_test_db.sh: Simplify ldata usage Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set) mysql-test/mysql-test-run.pl: Added --tmpdir=. to bootstrap mysql-test/mysql-test-run.sh: Use copy instead of INSTALL_DB for master and slave databases. (Speeds up startup time a lot!) Remove snapshot directories at startup (removes some strange warnings) mysql-test/r/binlog_row_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/r/binlog_stm_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment mysql-test/r/create.result: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/r/federated.result: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/r/func_gconcat.result: Enable some disabled tests (converted them slightly to be predictable) mysql-test/r/func_time.result: Added drop of test function mysql-test/r/innodb_mysql.result: Added tests for CREATE ... SELECT mysql-test/r/insert.result: More tests Added testing of duplicate columns in insert mysql-test/r/loaddata.result: Added testing LOAD DATA ... SET ... mysql-test/r/multi_update.result: Test multi updates and deletes using primary key and without mysql-test/r/ndb_index_unique.result: Better error message mysql-test/r/ndb_replace.result: New correct result after fixing REPLACE handling with NDB mysql-test/r/rpl_ddl.result: Now we don't get these (wrong) warnings anymore mysql-test/r/view_grant.result: Drop used views mysql-test/t/create.test: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/t/federated.test: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/t/func_gconcat.test: Enable some disabled tests (converted them slightly to be predictable) mysql-test/t/func_time.test: Added drop of test function mysql-test/t/innodb_mysql.test: Added tests for CREATE ... SELECT mysql-test/t/insert.test: More tests Added testing of duplicate columns in insert mysql-test/t/loaddata.test: Added testing LOAD DATA ... SET ... mysql-test/t/multi_update.test: Test multi updates and deletes using primary key and without mysql-test/t/view_grant.test: Drop used views mysql-test/valgrind.supp: Added supression of not needed warnings when printing stack trace mysys/base64.c: Include my_global.h first mysys/my_bitmap.c: Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy() Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström) Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed. Changed how mutex is allocated to make 'bitmap_free()' function simpler. mysys/thr_lock.c: Added 0x before thread pointers (for easier comparison of DBUG traces) sql/event.cc: Ensure 'use_all_columns()' is used for event tables Don't print warning that event table is damaged if it doesn't exists. sql/field.cc: Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set (Rest of changes are only indentation cleanups) sql/field.h: Removed Field->query_id (replaced by table->read_set and table->write_set) Removed Field->fieldnr (use Field->field_index instead) Removed Field->add_index (Use Field->flags instead) Add Field->part_of_key_not_clustered (for usage in opt_range.cc) sql/filesort.cc: Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set. This allowed me to remove checking of sql_command. Create a temporary column bitmap for fields that are used by the sorting process. Use column bitmaps instead of query_id sql/ha_berkeley.cc: Update to 'newer' table handler interface sql/ha_berkeley.h: Update to 'newer' table handler interface sql/ha_federated.cc: Update to 'newer' table handler interface Only read columns that are needed from remote server. In case of eq ranges, don't generate two conditions in the WHERE clause (this can still be optimized, but would require a bigger code change) Use 'simpler to use' XXXX_LEN' macros A bit simpler logic in ::write_row() when creating statements. In update, only include test of fields actually read. (This greatly simplifies the queries sent by the federated engine) Similar changes done for delete_row() sql/ha_federated.h: Update to 'newer' table handler interface Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE sql/ha_heap.cc: Update to 'newer' table handler interface sql/ha_heap.h: Update to 'newer' table handler interface sql/ha_innodb.cc: Update to 'newer' table handler interface - Update innobase_create_handler() to new interface - Removed HA_NOT_EXACT_COUNT (not needed) - Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - Prefixed base status variables with 'stats' - Use table column bitmaps instead of ha_get_bit_in_read_set() - Added ::reset(), with code from ::extra(HA_EXTRA_RESET) - Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as the table->read_set and table->write_set bitmaps now are accurate sql/ha_innodb.h: Update to 'newer' table handler interface - table_flags are now ulonglong - Added reset() method - Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns. - Made build_template() a class function to be able to easier access class variables sql/ha_myisam.cc: Update to 'newer' table handler interface sql/ha_myisam.h: Update to 'newer' table handler interface sql/ha_myisammrg.cc: Update to 'newer' table handler interface sql/ha_myisammrg.h: Update to 'newer' table handler interface sql/ha_ndbcluster.cc: Update to 'newer' table handler interface Fixed use_blob_value() to be accurate In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map Correct dumping of field data with DBUG_DUMP Prefix addresses in DBUG_PRINT with 0x Fixed usage of not initialized memory Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index. sql/ha_ndbcluster.h: Update to 'newer' table handler interface sql/ha_ndbcluster_binlog.cc: Mark usage of all columns in ndbcluster binlog tables false -> FALSE, true -> TRUE Use table->s->all_set instead of creating a temporary bitmap. sql/ha_partition.cc: Update to 'newer' table handler interface Added memroot to initialise_partitions() and related functions to get faster memory allocation. partition_create_handler() is now responsible for initialisation of the partition object Some trivial optimizations and indentation fixes Ensure that table_flags() are up to date Removed documentation for removed HA_EXTRA flags Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance' sql/ha_partition.h: Update to 'newer' table handler interface sql/handler.cc: create_xxx handler now takes MEMROOT as an argument to simplify memory allocation. Much simpler get_new_handler() (Initialization of the object is now handled by the create method for the engine) Moved all allocation of bitmap handling to the TABLE object (in table.cc) Added column_bitmaps_signal() to signal column usage changes. Changed binlog_log_row() to use the exiusting all_set bitmap in the table object. Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset() Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row sql/handler.h: Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME HA_DUPP_POS -> HA_DUPLICATE_POS HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records() HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION Added future row type 'ROW_TYPE_PAGES' Added MEM_ROOT to handlerton 'create' function Added ha_statistics, a structure for all status variable in the base handler class. Moved all status variables in the handler class into a stats structs to improve readability. ha_table_flags() is now a cached (not virtual) version of table_flags() reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own. Renamed dupp_ref to dup_ref Renamed not used handler::sortkey Moved read_set and write_set to TABLE structure handler::init() function added for cacheing of virtual constants from engine. sql/item.cc: Added register_field_in_read_map() for marking used columns in expression. This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting. Initalize value.cs_info.character_set_client to fix core dump bug with --debug set_query_id -> mark_used_columns Mark used columns in read_set OR write_set. sql/item.h: Removed reset_query_id_processor() as it's not needed anymore. Added register_field_in_read_map() Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_cmpfunc.cc: Temporary mark used columns to be read/writable Update Item::walk to new interface sql/item_cmpfunc.h: Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_func.cc: Update Item::walk() to new interface table_flags() -> ha_table_flags() sql/item_func.h: Update Item::walk() to new interface sql/item_row.cc: Update Item::walk() to new interface sql/item_row.h: Update Item::walk() to new interface sql/item_strfunc.h: Update Item::walk() to new interface sql/item_subselect.cc: Added Item_subselect::walk() (It was a bug it was missing before. Not sure what kind of bugs this could have caused) sql/item_subselect.h: Update Item::walk() to new interface sql/item_sum.cc: Update Item::walk() to new interface Updates for new handler interace sql/item_sum.h: Update Item::walk() to new interface sql/key.cc: Updates for new handler interace sql/log.cc: Mark all columns used for log tables Split options flag Ensured that second argument to trans_register_ha is a bool sql/log_event.cc: Fixed comments to be withing 79 characters Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings Updates for new handler interface Use 0x%lx instead of %p (portability problem) sql/mysql_priv.h: Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback Removed not used 'conds' argument to setup_tables sql/mysqld.cc: Indentation fixes and removed old comment sql/opt_range.cc: Update to new handler and bitmap interface. Fixed calls to cp_buffer_from_ref() and walk() (new argument). Create new temporary bitmaps for ror scans. (Needed because of handler changes and to get more accurate column bitmaps than before) Remove not needed file->ha_reset() call before file->close(). Some trivial optimization and indentation fixes. Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts. Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record. This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling. (This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans) Optimized bitmap handling in ror scans: - Start bitmap at position 0, not 1 - Use same bitmap size as in TABLE - Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table sql/opt_range.h: Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan Added temporary column bitmaps used in ROR scans sql/opt_sum.cc: Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set. sql/protocol.cc: We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user sql/records.cc: Updates for new handler interface sql/set_var.cc: Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags sql/share/errmsg.txt: Fixed wrong sql/sp.cc: Mark that we are using all columns for the proc table Update call to setup_tables() to use new prototype sql/sp_head.cc: Removed QQ comment sql/spatial.cc: Removed wrong QQ comment sql/sql_acl.cc: Mark that we need all columns for acl tables Supply memroot to some 'new' calls. Indentation fixes sql/sql_base.cc: set_query_id removed Ensure we call ha_reset() at end of each statement Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set) Fixed marking of some columns that was not proplerly marked before Maintain in TABLE->merge_keys set of all keys that are used in some way Removed not used 'conds' argument from setup_tables() Remove not used setting of 'dupp_field' in insert_fields() Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) sql/sql_bitmap.h: Added is_overlapping() sql/sql_class.cc: Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. set_query_id -> mark_used_columns Simpler variable usage in pack_row() (cleanup) Moved some variable declartion at start of function for better code readability sql/sql_class.h: Added enum_mark_columns Updated comments Renamed dupp_field -> dup_field Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE. (This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables) sql/sql_delete.cc: Updates to new handler interface Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires. Call table->prepare_for_position() to tell handler that we are going to call ha_position(). Removed call to free_io_cache(). (io_cache is now removed in ha_reset()). Fixed calls to setup_tables() sql/sql_do.cc: Update call to setup_fields() sql/sql_handler.cc: Tell handler tables to always read all columns. Use temporary column map when storing value in field for later index usage sql/sql_help.cc: Makr all used fields to be read Update call to setup_fields() sql/sql_insert.cc: Tell handler we are going to update the auto_increment column dupp_field -> dup_field Set column usage bits for timestamp field. Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column() Removed not used argument from mysql_prepare_insert_check_table(). If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. Setup new bitmaps for delayed insert rows Remove reseting of next_number_fields as it will be reset on next call to handler_insert() Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE. The issue was that one should not to reset this flag as it may be set by a previous statement. The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional. I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done) Don't close tables created with CREATE ... SELECT but keep them in the table cache. Moved out MY_HOOKS from inside function (better readability) sql/sql_load.cc: Update to use new handler and column marking interface Update using setup_tables() sql/sql_olap.cc: Update calls to setup_tables Use enums instead of constants to setup_fields() sql/sql_parse.cc: Handle OPTION_KEEP_LOG: - Set it on CREATE TEMPORARY TABLE / DROP TABLE - Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset - Don't set it for CREATE ... SELECT (this is handled in select_create class) Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset. If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands sql/sql_partition.cc: Update walk() usage Trivial indentation fixes sql/sql_plugin.cc: Mark all columns as used for plugins sql/sql_prepare.cc: Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly) Updates for new handler interface Update calls to setup_fields() sql/sql_repl.cc: Indentation fixes sql/sql_select.cc: Update call to setup_tables() and setup_fields() Remove some old disabled code Update to new hadler interface Indentation cleanups Added column bitmaps for temporary tables. Remove updating of the removed slots in the Field class Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps) For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. sql/sql_select.h: Indentaition fixes. Install temporary column usage maps when needed Added TABLE element to cp_buffer_from_ref() sql/sql_show.cc: Update to new handler interface Mark all columns used for internal tables. Style fixes. Added support for 'future' ROW_TYPE_PAGES. Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly. sql/sql_table.cc: Update to new handler interface Simple my_snprintf -> strmake() Changed some constants to defines Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL) Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX Mark all columns as used for ALTER TABLE Style fixes Update call to filesort() sql/sql_trigger.h: Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in. sql/sql_udf.cc: Mark all columns as used for udf system table. sql/sql_union.cc: Update call to walk() Update to new handler interface sql/sql_update.cc: Remove query_id argument from compare_record() Use column bitmaps instead of query_id. We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value. Update call to setup_fields() Using separate column read and write sets allows for easier checking of timestamp field was set by statement. Removed call to free_io_cache() as this is now done in ha_reset() Call table->mark_columns_needed_for_update() and table->prepare_for_position() Style fixes sql/sql_view.cc: Style fixes sql/table.cc: Remove implicitely include 'errno.h' Remove code for building normalized path, as this is now identical to 'path' Remove field->fieldnr Added update of field->part_of_key_not_clustered() Create column bitmaps in TABLE and TABLE_SHARE Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler() Update to new handler interface Update call to walk() Added new functions: - st_table::clear_column_bitmaps() - st_table::prepare_for_position() - st_table::mark_columns_used_by_index() - st_table::restore_column_maps_after_mark_index() - st_table::mark_columns_used_by_index_no_reset() - st_table::mark_auto_increment_column() - st_table::mark_columns_needed_for_delete() - st_table::mark_columns_needed_for_update() - st_table::mark_columns_needed_for_insert() sql/table.h: Moved column usage bitmaps from handler to TABLE Added to TABLE_SHARE all_set and column_bitmap_size Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set. Declared all new table column bitmap functions Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps() Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val(). sql/tztime.cc: Mark all columns as used for timezone tables storage/archive/ha_archive.cc: Update to new handler interface storage/archive/ha_archive.h: Update to new handler interface storage/blackhole/ha_blackhole.cc: Update to new handler interface storage/blackhole/ha_blackhole.h: Update to new handler interface removed not needed flag HA_DUPP_POS storage/csv/ha_tina.cc: Update to new handler interface storage/csv/ha_tina.h: Update to new handler interface storage/example/ha_example.cc: Update to new handler interface storage/example/ha_example.h: Update to new handler interface storage/heap/hp_extra.c: Added heap_reset() (Required by new handler interface) storage/heap/hp_test2.c: Use heap_reset() storage/myisam/ft_boolean_search.c: Fixed compiler warning storage/myisam/mi_extra.c: Added mi_reset() (Required by new handler interface) storage/myisam/mi_search.c: Fixed DBUG_PRINT messages to use 0x%lx instead of %lx storage/myisam/mi_test2.c: Use mi_reset() storage/myisam/myisampack.c: Use mi_reset() storage/myisammrg/myrg_extra.c: Added myrg_reset() (Required by new handler interface) unittest/mysys/base64.t.c: Include my_global.h Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
if (walk_subquery)
{
for (SELECT_LEX *lex= unit->first_select(); lex; lex= lex->next_select())
{
List_iterator<Item> li(lex->item_list);
Item *item;
ORDER *order;
if (lex->where && (lex->where)->walk(processor, walk_subquery, argument))
return 1;
if (lex->having && (lex->having)->walk(processor, walk_subquery,
argument))
return 1;
/* TODO: why does this walk WHERE/HAVING but not ON expressions of outer joins? */
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes Changes that requires code changes in other code of other storage engines. (Note that all changes are very straightforward and one should find all issues by compiling a --debug build and fixing all compiler errors and all asserts in field.cc while running the test suite), - New optional handler function introduced: reset() This is called after every DML statement to make it easy for a handler to statement specific cleanups. (The only case it's not called is if force the file to be closed) - handler::extra(HA_EXTRA_RESET) is removed. Code that was there before should be moved to handler::reset() - table->read_set contains a bitmap over all columns that are needed in the query. read_row() and similar functions only needs to read these columns - table->write_set contains a bitmap over all columns that will be updated in the query. write_row() and update_row() only needs to update these columns. The above bitmaps should now be up to date in all context (including ALTER TABLE, filesort()). The handler is informed of any changes to the bitmap after fix_fields() by calling the virtual function handler::column_bitmaps_signal(). If the handler does caching of these bitmaps (instead of using table->read_set, table->write_set), it should redo the caching in this code. as the signal() may be sent several times, it's probably best to set a variable in the signal and redo the caching on read_row() / write_row() if the variable was set. - Removed the read_set and write_set bitmap objects from the handler class - Removed all column bit handling functions from the handler class. (Now one instead uses the normal bitmap functions in my_bitmap.c instead of handler dedicated bitmap functions) - field->query_id is removed. One should instead instead check table->read_set and table->write_set if a field is used in the query. - handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now instead use table->read_set to check for which columns to retrieve. - If a handler needs to call Field->val() or Field->store() on columns that are not used in the query, one should install a temporary all-columns-used map while doing so. For this, we provide the following functions: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); field->val(); dbug_tmp_restore_column_map(table->read_set, old_map); and similar for the write map: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); field->val(); dbug_tmp_restore_column_map(table->write_set, old_map); If this is not done, you will sooner or later hit a DBUG_ASSERT in the field store() / val() functions. (For not DBUG binaries, the dbug_tmp_restore_column_map() and dbug_tmp_restore_column_map() are inline dummy functions and should be optimized away be the compiler). - If one needs to temporary set the column map for all binaries (and not just to avoid the DBUG_ASSERT() in the Field::store() / Field::val() methods) one should use the functions tmp_use_all_columns() and tmp_restore_column_map() instead of the above dbug_ variants. - All 'status' fields in the handler base class (like records, data_file_length etc) are now stored in a 'stats' struct. This makes it easier to know what status variables are provided by the base handler. This requires some trivial variable names in the extra() function. - New virtual function handler::records(). This is called to optimize COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true. (stats.records is not supposed to be an exact value. It's only has to be 'reasonable enough' for the optimizer to be able to choose a good optimization path). - Non virtual handler::init() function added for caching of virtual constants from engine. - Removed has_transactions() virtual method. Now one should instead return HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support transactions. - The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument that is to be used with 'new handler_name()' to allocate the handler in the right area. The xxxx_create_handler() function is also responsible for any initialization of the object before returning. For example, one should change: static handler *myisam_create_handler(TABLE_SHARE *table) { return new ha_myisam(table); } -> static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { return new (mem_root) ha_myisam(table); } - New optional virtual function: use_hidden_primary_key(). This is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined but we don't have a primary key. This allows the handler to take precisions in remembering any hidden primary key to able to update/delete any found row. The default handler marks all columns to be read. - handler::table_flags() now returns a ulonglong (to allow for more flags). - New/changed table_flags() - HA_HAS_RECORDS Set if ::records() is supported - HA_NO_TRANSACTIONS Set if engine doesn't support transactions - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE Set if we should mark all primary key columns for read when reading rows as part of a DELETE statement. If there is no primary key, all columns are marked for read. - HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some cases (based on table->read_set) - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - HA_DUPP_POS Renamed to HA_DUPLICATE_POS - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE Set this if we should mark ALL key columns for read when when reading rows as part of a DELETE statement. In case of an update we will mark all keys for read for which key part changed value. - HA_STATS_RECORDS_IS_EXACT Set this if stats.records is exact. (This saves us some extra records() calls when optimizing COUNT(*)) - Removed table_flags() - HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if handler::records() gives an exact count() and HA_STATS_RECORDS_IS_EXACT if stats.records is exact. - HA_READ_RND_SAME Removed (no one supported this one) - Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk() - Renamed handler::dupp_pos to handler::dup_pos - Removed not used variable handler::sortkey Upper level handler changes: - ha_reset() now does some overall checks and calls ::reset() - ha_table_flags() added. This is a cached version of table_flags(). The cache is updated on engine creation time and updated on open. MySQL level changes (not obvious from the above): - DBUG_ASSERT() added to check that column usage matches what is set in the column usage bit maps. (This found a LOT of bugs in current column marking code). - In 5.1 before, all used columns was marked in read_set and only updated columns was marked in write_set. Now we only mark columns for which we need a value in read_set. - Column bitmaps are created in open_binary_frm() and open_table_from_share(). (Before this was in table.cc) - handler::table_flags() calls are replaced with handler::ha_table_flags() - For calling field->val() you must have the corresponding bit set in table->read_set. For calling field->store() you must have the corresponding bit set in table->write_set. (There are asserts in all store()/val() functions to catch wrong usage) - thd->set_query_id is renamed to thd->mark_used_columns and instead of setting this to an integer value, this has now the values: MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE Changed also all variables named 'set_query_id' to mark_used_columns. - In filesort() we now inform the handler of exactly which columns are needed doing the sort and choosing the rows. - The TABLE_SHARE object has a 'all_set' column bitmap one can use when one needs a column bitmap with all columns set. (This is used for table->use_all_columns() and other places) - The TABLE object has 3 column bitmaps: - def_read_set Default bitmap for columns to be read - def_write_set Default bitmap for columns to be written - tmp_set Can be used as a temporary bitmap when needed. The table object has also two pointer to bitmaps read_set and write_set that the handler should use to find out which columns are used in which way. - count() optimization now calls handler::records() instead of using handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true). - Added extra argument to Item::walk() to indicate if we should also traverse sub queries. - Added TABLE parameter to cp_buffer_from_ref() - Don't close tables created with CREATE ... SELECT but keep them in the table cache. (Faster usage of newly created tables). New interfaces: - table->clear_column_bitmaps() to initialize the bitmaps for tables at start of new statements. - table->column_bitmaps_set() to set up new column bitmaps and signal the handler about this. - table->column_bitmaps_set_no_signal() for some few cases where we need to setup new column bitmaps but don't signal the handler (as the handler has already been signaled about these before). Used for the momement only in opt_range.cc when doing ROR scans. - table->use_all_columns() to install a bitmap where all columns are marked as use in the read and the write set. - table->default_column_bitmaps() to install the normal read and write column bitmaps, but not signaling the handler about this. This is mainly used when creating TABLE instances. - table->mark_columns_needed_for_delete(), table->mark_columns_needed_for_delete() and table->mark_columns_needed_for_insert() to allow us to put additional columns in column usage maps if handler so requires. (The handler indicates what it neads in handler->table_flags()) - table->prepare_for_position() to allow us to tell handler that it needs to read primary key parts to be able to store them in future table->position() calls. (This replaces the table->file->ha_retrieve_all_pk function) - table->mark_auto_increment_column() to tell handler are going to update columns part of any auto_increment key. - table->mark_columns_used_by_index() to mark all columns that is part of an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow it to quickly know that it only needs to read colums that are part of the key. (The handler can also use the column map for detecting this, but simpler/faster handler can just monitor the extra() call). - table->mark_columns_used_by_index_no_reset() to in addition to other columns, also mark all columns that is used by the given key. - table->restore_column_maps_after_mark_index() to restore to default column maps after a call to table->mark_columns_used_by_index(). - New item function register_field_in_read_map(), for marking used columns in table->read_map. Used by filesort() to mark all used columns - Maintain in TABLE->merge_keys set of all keys that are used in query. (Simplices some optimization loops) - Maintain Field->part_of_key_not_clustered which is like Field->part_of_key but the field in the clustered key is not assumed to be part of all index. (used in opt_range.cc for faster loops) - dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map() tmp_use_all_columns() and tmp_restore_column_map() functions to temporally mark all columns as usable. The 'dbug_' version is primarily intended inside a handler when it wants to just call Field:store() & Field::val() functions, but don't need the column maps set for any other usage. (ie:: bitmap_is_set() is never called) - We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set. The reason for this is that if we have a column marked only for write we can't in the MySQL level know if the value changed or not. The reason this worked before was that MySQL marked all to be written columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden bug'. - open_table_from_share() does not anymore setup temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler(). (Simpler, faster code) Bugs fixed: - Column marking was not done correctly in a lot of cases. (ALTER TABLE, when using triggers, auto_increment fields etc) (Could potentially result in wrong values inserted in table handlers relying on that the old column maps or field->set_query_id was correct) Especially when it comes to triggers, there may be cases where the old code would cause lost/wrong values for NDB and/or InnoDB tables. - Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags: OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG. This allowed me to remove some wrong warnings about: "Some non-transactional changed tables couldn't be rolled back" - Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose some warnings about "Some non-transactional changed tables couldn't be rolled back") - Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table() which could cause delete_table to report random failures. - Fixed core dumps for some tests when running with --debug - Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) - slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. - If we get an duplicate row on insert, change column map to read and write all columns while retrying the operation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. - For table handler that doesn't support NULL in keys, we would give an error when creating a primary key with NULL fields, even after the fields has been automaticly converted to NOT NULL. - Creating a primary key on a SPATIAL key, would fail if field was not declared as NOT NULL. Cleanups: - Removed not used condition argument to setup_tables - Removed not needed item function reset_query_id_processor(). - Field->add_index is removed. Now this is instead maintained in (field->flags & FIELD_IN_ADD_INDEX) - Field->fieldnr is removed (use field->field_index instead) - New argument to filesort() to indicate that it should return a set of row pointers (not used columns). This allowed me to remove some references to sql_command in filesort and should also enable us to return column results in some cases where we couldn't before. - Changed column bitmap handling in opt_range.cc to be aligned with TABLE bitmap, which allowed me to use bitmap functions instead of looping over all fields to create some needed bitmaps. (Faster and smaller code) - Broke up found too long lines - Moved some variable declaration at start of function for better code readability. - Removed some not used arguments from functions. (setup_fields(), mysql_prepare_insert_check_table()) - setup_fields() now takes an enum instead of an int for marking columns usage. - For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. - Changed some constants to enum's and define's. - Using separate column read and write sets allows for easier checking of timestamp field was set by statement. - Remove calls to free_io_cache() as this is now done automaticly in ha_reset() - Don't build table->normalized_path as this is now identical to table->path (after bar's fixes to convert filenames) - Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to do comparision with the 'convert-dbug-for-diff' tool. Things left to do in 5.1: - We wrongly log failed CREATE TABLE ... SELECT in some cases when using row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result) Mats has promised to look into this. - Test that my fix for CREATE TABLE ... SELECT is indeed correct. (I added several test cases for this, but in this case it's better that someone else also tests this throughly). Lars has promosed to do this. BitKeeper/etc/ignore: added mysys/test_bitmap include/base64.h: Removed my_global.h, as this must be included first in any program include/heap.h: Added heap_reset() (Required by new handler interface) include/my_base.h: Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET). HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary include/my_bitmap.h: Remove my_pthread.h (should be included at upper level) Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp() Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void include/myisam.h: Added mi_reset() (Required by new handler interface) include/myisammrg.h: Added myrg_reset() (Required by new handler interface) include/mysql_com.h: Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/install_test_db.sh: Simplify ldata usage Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set) mysql-test/mysql-test-run.pl: Added --tmpdir=. to bootstrap mysql-test/mysql-test-run.sh: Use copy instead of INSTALL_DB for master and slave databases. (Speeds up startup time a lot!) Remove snapshot directories at startup (removes some strange warnings) mysql-test/r/binlog_row_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/r/binlog_stm_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment mysql-test/r/create.result: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/r/federated.result: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/r/func_gconcat.result: Enable some disabled tests (converted them slightly to be predictable) mysql-test/r/func_time.result: Added drop of test function mysql-test/r/innodb_mysql.result: Added tests for CREATE ... SELECT mysql-test/r/insert.result: More tests Added testing of duplicate columns in insert mysql-test/r/loaddata.result: Added testing LOAD DATA ... SET ... mysql-test/r/multi_update.result: Test multi updates and deletes using primary key and without mysql-test/r/ndb_index_unique.result: Better error message mysql-test/r/ndb_replace.result: New correct result after fixing REPLACE handling with NDB mysql-test/r/rpl_ddl.result: Now we don't get these (wrong) warnings anymore mysql-test/r/view_grant.result: Drop used views mysql-test/t/create.test: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/t/federated.test: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/t/func_gconcat.test: Enable some disabled tests (converted them slightly to be predictable) mysql-test/t/func_time.test: Added drop of test function mysql-test/t/innodb_mysql.test: Added tests for CREATE ... SELECT mysql-test/t/insert.test: More tests Added testing of duplicate columns in insert mysql-test/t/loaddata.test: Added testing LOAD DATA ... SET ... mysql-test/t/multi_update.test: Test multi updates and deletes using primary key and without mysql-test/t/view_grant.test: Drop used views mysql-test/valgrind.supp: Added supression of not needed warnings when printing stack trace mysys/base64.c: Include my_global.h first mysys/my_bitmap.c: Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy() Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström) Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed. Changed how mutex is allocated to make 'bitmap_free()' function simpler. mysys/thr_lock.c: Added 0x before thread pointers (for easier comparison of DBUG traces) sql/event.cc: Ensure 'use_all_columns()' is used for event tables Don't print warning that event table is damaged if it doesn't exists. sql/field.cc: Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set (Rest of changes are only indentation cleanups) sql/field.h: Removed Field->query_id (replaced by table->read_set and table->write_set) Removed Field->fieldnr (use Field->field_index instead) Removed Field->add_index (Use Field->flags instead) Add Field->part_of_key_not_clustered (for usage in opt_range.cc) sql/filesort.cc: Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set. This allowed me to remove checking of sql_command. Create a temporary column bitmap for fields that are used by the sorting process. Use column bitmaps instead of query_id sql/ha_berkeley.cc: Update to 'newer' table handler interface sql/ha_berkeley.h: Update to 'newer' table handler interface sql/ha_federated.cc: Update to 'newer' table handler interface Only read columns that are needed from remote server. In case of eq ranges, don't generate two conditions in the WHERE clause (this can still be optimized, but would require a bigger code change) Use 'simpler to use' XXXX_LEN' macros A bit simpler logic in ::write_row() when creating statements. In update, only include test of fields actually read. (This greatly simplifies the queries sent by the federated engine) Similar changes done for delete_row() sql/ha_federated.h: Update to 'newer' table handler interface Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE sql/ha_heap.cc: Update to 'newer' table handler interface sql/ha_heap.h: Update to 'newer' table handler interface sql/ha_innodb.cc: Update to 'newer' table handler interface - Update innobase_create_handler() to new interface - Removed HA_NOT_EXACT_COUNT (not needed) - Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - Prefixed base status variables with 'stats' - Use table column bitmaps instead of ha_get_bit_in_read_set() - Added ::reset(), with code from ::extra(HA_EXTRA_RESET) - Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as the table->read_set and table->write_set bitmaps now are accurate sql/ha_innodb.h: Update to 'newer' table handler interface - table_flags are now ulonglong - Added reset() method - Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns. - Made build_template() a class function to be able to easier access class variables sql/ha_myisam.cc: Update to 'newer' table handler interface sql/ha_myisam.h: Update to 'newer' table handler interface sql/ha_myisammrg.cc: Update to 'newer' table handler interface sql/ha_myisammrg.h: Update to 'newer' table handler interface sql/ha_ndbcluster.cc: Update to 'newer' table handler interface Fixed use_blob_value() to be accurate In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map Correct dumping of field data with DBUG_DUMP Prefix addresses in DBUG_PRINT with 0x Fixed usage of not initialized memory Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index. sql/ha_ndbcluster.h: Update to 'newer' table handler interface sql/ha_ndbcluster_binlog.cc: Mark usage of all columns in ndbcluster binlog tables false -> FALSE, true -> TRUE Use table->s->all_set instead of creating a temporary bitmap. sql/ha_partition.cc: Update to 'newer' table handler interface Added memroot to initialise_partitions() and related functions to get faster memory allocation. partition_create_handler() is now responsible for initialisation of the partition object Some trivial optimizations and indentation fixes Ensure that table_flags() are up to date Removed documentation for removed HA_EXTRA flags Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance' sql/ha_partition.h: Update to 'newer' table handler interface sql/handler.cc: create_xxx handler now takes MEMROOT as an argument to simplify memory allocation. Much simpler get_new_handler() (Initialization of the object is now handled by the create method for the engine) Moved all allocation of bitmap handling to the TABLE object (in table.cc) Added column_bitmaps_signal() to signal column usage changes. Changed binlog_log_row() to use the exiusting all_set bitmap in the table object. Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset() Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row sql/handler.h: Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME HA_DUPP_POS -> HA_DUPLICATE_POS HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records() HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION Added future row type 'ROW_TYPE_PAGES' Added MEM_ROOT to handlerton 'create' function Added ha_statistics, a structure for all status variable in the base handler class. Moved all status variables in the handler class into a stats structs to improve readability. ha_table_flags() is now a cached (not virtual) version of table_flags() reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own. Renamed dupp_ref to dup_ref Renamed not used handler::sortkey Moved read_set and write_set to TABLE structure handler::init() function added for cacheing of virtual constants from engine. sql/item.cc: Added register_field_in_read_map() for marking used columns in expression. This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting. Initalize value.cs_info.character_set_client to fix core dump bug with --debug set_query_id -> mark_used_columns Mark used columns in read_set OR write_set. sql/item.h: Removed reset_query_id_processor() as it's not needed anymore. Added register_field_in_read_map() Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_cmpfunc.cc: Temporary mark used columns to be read/writable Update Item::walk to new interface sql/item_cmpfunc.h: Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_func.cc: Update Item::walk() to new interface table_flags() -> ha_table_flags() sql/item_func.h: Update Item::walk() to new interface sql/item_row.cc: Update Item::walk() to new interface sql/item_row.h: Update Item::walk() to new interface sql/item_strfunc.h: Update Item::walk() to new interface sql/item_subselect.cc: Added Item_subselect::walk() (It was a bug it was missing before. Not sure what kind of bugs this could have caused) sql/item_subselect.h: Update Item::walk() to new interface sql/item_sum.cc: Update Item::walk() to new interface Updates for new handler interace sql/item_sum.h: Update Item::walk() to new interface sql/key.cc: Updates for new handler interace sql/log.cc: Mark all columns used for log tables Split options flag Ensured that second argument to trans_register_ha is a bool sql/log_event.cc: Fixed comments to be withing 79 characters Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings Updates for new handler interface Use 0x%lx instead of %p (portability problem) sql/mysql_priv.h: Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback Removed not used 'conds' argument to setup_tables sql/mysqld.cc: Indentation fixes and removed old comment sql/opt_range.cc: Update to new handler and bitmap interface. Fixed calls to cp_buffer_from_ref() and walk() (new argument). Create new temporary bitmaps for ror scans. (Needed because of handler changes and to get more accurate column bitmaps than before) Remove not needed file->ha_reset() call before file->close(). Some trivial optimization and indentation fixes. Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts. Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record. This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling. (This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans) Optimized bitmap handling in ror scans: - Start bitmap at position 0, not 1 - Use same bitmap size as in TABLE - Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table sql/opt_range.h: Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan Added temporary column bitmaps used in ROR scans sql/opt_sum.cc: Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set. sql/protocol.cc: We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user sql/records.cc: Updates for new handler interface sql/set_var.cc: Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags sql/share/errmsg.txt: Fixed wrong sql/sp.cc: Mark that we are using all columns for the proc table Update call to setup_tables() to use new prototype sql/sp_head.cc: Removed QQ comment sql/spatial.cc: Removed wrong QQ comment sql/sql_acl.cc: Mark that we need all columns for acl tables Supply memroot to some 'new' calls. Indentation fixes sql/sql_base.cc: set_query_id removed Ensure we call ha_reset() at end of each statement Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set) Fixed marking of some columns that was not proplerly marked before Maintain in TABLE->merge_keys set of all keys that are used in some way Removed not used 'conds' argument from setup_tables() Remove not used setting of 'dupp_field' in insert_fields() Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) sql/sql_bitmap.h: Added is_overlapping() sql/sql_class.cc: Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. set_query_id -> mark_used_columns Simpler variable usage in pack_row() (cleanup) Moved some variable declartion at start of function for better code readability sql/sql_class.h: Added enum_mark_columns Updated comments Renamed dupp_field -> dup_field Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE. (This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables) sql/sql_delete.cc: Updates to new handler interface Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires. Call table->prepare_for_position() to tell handler that we are going to call ha_position(). Removed call to free_io_cache(). (io_cache is now removed in ha_reset()). Fixed calls to setup_tables() sql/sql_do.cc: Update call to setup_fields() sql/sql_handler.cc: Tell handler tables to always read all columns. Use temporary column map when storing value in field for later index usage sql/sql_help.cc: Makr all used fields to be read Update call to setup_fields() sql/sql_insert.cc: Tell handler we are going to update the auto_increment column dupp_field -> dup_field Set column usage bits for timestamp field. Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column() Removed not used argument from mysql_prepare_insert_check_table(). If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. Setup new bitmaps for delayed insert rows Remove reseting of next_number_fields as it will be reset on next call to handler_insert() Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE. The issue was that one should not to reset this flag as it may be set by a previous statement. The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional. I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done) Don't close tables created with CREATE ... SELECT but keep them in the table cache. Moved out MY_HOOKS from inside function (better readability) sql/sql_load.cc: Update to use new handler and column marking interface Update using setup_tables() sql/sql_olap.cc: Update calls to setup_tables Use enums instead of constants to setup_fields() sql/sql_parse.cc: Handle OPTION_KEEP_LOG: - Set it on CREATE TEMPORARY TABLE / DROP TABLE - Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset - Don't set it for CREATE ... SELECT (this is handled in select_create class) Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset. If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands sql/sql_partition.cc: Update walk() usage Trivial indentation fixes sql/sql_plugin.cc: Mark all columns as used for plugins sql/sql_prepare.cc: Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly) Updates for new handler interface Update calls to setup_fields() sql/sql_repl.cc: Indentation fixes sql/sql_select.cc: Update call to setup_tables() and setup_fields() Remove some old disabled code Update to new hadler interface Indentation cleanups Added column bitmaps for temporary tables. Remove updating of the removed slots in the Field class Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps) For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. sql/sql_select.h: Indentaition fixes. Install temporary column usage maps when needed Added TABLE element to cp_buffer_from_ref() sql/sql_show.cc: Update to new handler interface Mark all columns used for internal tables. Style fixes. Added support for 'future' ROW_TYPE_PAGES. Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly. sql/sql_table.cc: Update to new handler interface Simple my_snprintf -> strmake() Changed some constants to defines Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL) Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX Mark all columns as used for ALTER TABLE Style fixes Update call to filesort() sql/sql_trigger.h: Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in. sql/sql_udf.cc: Mark all columns as used for udf system table. sql/sql_union.cc: Update call to walk() Update to new handler interface sql/sql_update.cc: Remove query_id argument from compare_record() Use column bitmaps instead of query_id. We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value. Update call to setup_fields() Using separate column read and write sets allows for easier checking of timestamp field was set by statement. Removed call to free_io_cache() as this is now done in ha_reset() Call table->mark_columns_needed_for_update() and table->prepare_for_position() Style fixes sql/sql_view.cc: Style fixes sql/table.cc: Remove implicitely include 'errno.h' Remove code for building normalized path, as this is now identical to 'path' Remove field->fieldnr Added update of field->part_of_key_not_clustered() Create column bitmaps in TABLE and TABLE_SHARE Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler() Update to new handler interface Update call to walk() Added new functions: - st_table::clear_column_bitmaps() - st_table::prepare_for_position() - st_table::mark_columns_used_by_index() - st_table::restore_column_maps_after_mark_index() - st_table::mark_columns_used_by_index_no_reset() - st_table::mark_auto_increment_column() - st_table::mark_columns_needed_for_delete() - st_table::mark_columns_needed_for_update() - st_table::mark_columns_needed_for_insert() sql/table.h: Moved column usage bitmaps from handler to TABLE Added to TABLE_SHARE all_set and column_bitmap_size Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set. Declared all new table column bitmap functions Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps() Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val(). sql/tztime.cc: Mark all columns as used for timezone tables storage/archive/ha_archive.cc: Update to new handler interface storage/archive/ha_archive.h: Update to new handler interface storage/blackhole/ha_blackhole.cc: Update to new handler interface storage/blackhole/ha_blackhole.h: Update to new handler interface removed not needed flag HA_DUPP_POS storage/csv/ha_tina.cc: Update to new handler interface storage/csv/ha_tina.h: Update to new handler interface storage/example/ha_example.cc: Update to new handler interface storage/example/ha_example.h: Update to new handler interface storage/heap/hp_extra.c: Added heap_reset() (Required by new handler interface) storage/heap/hp_test2.c: Use heap_reset() storage/myisam/ft_boolean_search.c: Fixed compiler warning storage/myisam/mi_extra.c: Added mi_reset() (Required by new handler interface) storage/myisam/mi_search.c: Fixed DBUG_PRINT messages to use 0x%lx instead of %lx storage/myisam/mi_test2.c: Use mi_reset() storage/myisam/myisampack.c: Use mi_reset() storage/myisammrg/myrg_extra.c: Added myrg_reset() (Required by new handler interface) unittest/mysys/base64.t.c: Include my_global.h Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
while ((item=li++))
{
if (item->walk(processor, walk_subquery, argument))
return 1;
}
Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. One somewhat major source of strict-aliasing violations and related warnings is the SQL_LIST structure. For example, consider its member function `link_in_list` which takes a pointer to pointer of type T (any type) as a pointer to pointer to unsigned char. Dereferencing this pointer, which is done to reset the next field, violates strict-aliasing rules and might cause problems for surrounding code that uses the next field of the object being added to the list. The solution is to use templates to parametrize the SQL_LIST structure in order to deference the pointers with compatible types. As a side bonus, it becomes possible to remove quite a few casts related to acessing data members of SQL_LIST. sql/handler.h: Use the appropriate template type argument. sql/item.cc: Remove now-unnecessary cast. sql/item_subselect.cc: Remove now-unnecessary casts. sql/item_sum.cc: Use the appropriate template type argument. Remove now-unnecessary cast. sql/mysql_priv.h: Move SQL_LIST structure to sql_list.h Use the appropriate template type argument. sql/sp.cc: Remove now-unnecessary casts. sql/sql_delete.cc: Use the appropriate template type argument. Remove now-unnecessary casts. sql/sql_derived.cc: Remove now-unnecessary casts. sql/sql_lex.cc: Remove now-unnecessary casts. sql/sql_lex.h: SQL_LIST now takes a template type argument which must match the type of the elements of the list. Use forward declaration when the type is not available, it is used in pointers anyway. sql/sql_list.h: Rename SQL_LIST to SQL_I_List. The template parameter is the type of object that is stored in the list. sql/sql_olap.cc: Remove now-unnecessary casts. sql/sql_parse.cc: Remove now-unnecessary casts. sql/sql_prepare.cc: Remove now-unnecessary casts. sql/sql_select.cc: Remove now-unnecessary casts. sql/sql_show.cc: Remove now-unnecessary casts. sql/sql_table.cc: Remove now-unnecessary casts. sql/sql_trigger.cc: Remove now-unnecessary casts. sql/sql_union.cc: Remove now-unnecessary casts. sql/sql_update.cc: Remove now-unnecessary casts. sql/sql_view.cc: Remove now-unnecessary casts. sql/sql_yacc.yy: Remove now-unnecessary casts. storage/myisammrg/ha_myisammrg.cc: Remove now-unnecessary casts.
2010-06-10 22:45:22 +02:00
for (order= lex->order_list.first ; order; order= order->next)
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes Changes that requires code changes in other code of other storage engines. (Note that all changes are very straightforward and one should find all issues by compiling a --debug build and fixing all compiler errors and all asserts in field.cc while running the test suite), - New optional handler function introduced: reset() This is called after every DML statement to make it easy for a handler to statement specific cleanups. (The only case it's not called is if force the file to be closed) - handler::extra(HA_EXTRA_RESET) is removed. Code that was there before should be moved to handler::reset() - table->read_set contains a bitmap over all columns that are needed in the query. read_row() and similar functions only needs to read these columns - table->write_set contains a bitmap over all columns that will be updated in the query. write_row() and update_row() only needs to update these columns. The above bitmaps should now be up to date in all context (including ALTER TABLE, filesort()). The handler is informed of any changes to the bitmap after fix_fields() by calling the virtual function handler::column_bitmaps_signal(). If the handler does caching of these bitmaps (instead of using table->read_set, table->write_set), it should redo the caching in this code. as the signal() may be sent several times, it's probably best to set a variable in the signal and redo the caching on read_row() / write_row() if the variable was set. - Removed the read_set and write_set bitmap objects from the handler class - Removed all column bit handling functions from the handler class. (Now one instead uses the normal bitmap functions in my_bitmap.c instead of handler dedicated bitmap functions) - field->query_id is removed. One should instead instead check table->read_set and table->write_set if a field is used in the query. - handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now instead use table->read_set to check for which columns to retrieve. - If a handler needs to call Field->val() or Field->store() on columns that are not used in the query, one should install a temporary all-columns-used map while doing so. For this, we provide the following functions: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); field->val(); dbug_tmp_restore_column_map(table->read_set, old_map); and similar for the write map: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); field->val(); dbug_tmp_restore_column_map(table->write_set, old_map); If this is not done, you will sooner or later hit a DBUG_ASSERT in the field store() / val() functions. (For not DBUG binaries, the dbug_tmp_restore_column_map() and dbug_tmp_restore_column_map() are inline dummy functions and should be optimized away be the compiler). - If one needs to temporary set the column map for all binaries (and not just to avoid the DBUG_ASSERT() in the Field::store() / Field::val() methods) one should use the functions tmp_use_all_columns() and tmp_restore_column_map() instead of the above dbug_ variants. - All 'status' fields in the handler base class (like records, data_file_length etc) are now stored in a 'stats' struct. This makes it easier to know what status variables are provided by the base handler. This requires some trivial variable names in the extra() function. - New virtual function handler::records(). This is called to optimize COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true. (stats.records is not supposed to be an exact value. It's only has to be 'reasonable enough' for the optimizer to be able to choose a good optimization path). - Non virtual handler::init() function added for caching of virtual constants from engine. - Removed has_transactions() virtual method. Now one should instead return HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support transactions. - The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument that is to be used with 'new handler_name()' to allocate the handler in the right area. The xxxx_create_handler() function is also responsible for any initialization of the object before returning. For example, one should change: static handler *myisam_create_handler(TABLE_SHARE *table) { return new ha_myisam(table); } -> static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { return new (mem_root) ha_myisam(table); } - New optional virtual function: use_hidden_primary_key(). This is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined but we don't have a primary key. This allows the handler to take precisions in remembering any hidden primary key to able to update/delete any found row. The default handler marks all columns to be read. - handler::table_flags() now returns a ulonglong (to allow for more flags). - New/changed table_flags() - HA_HAS_RECORDS Set if ::records() is supported - HA_NO_TRANSACTIONS Set if engine doesn't support transactions - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE Set if we should mark all primary key columns for read when reading rows as part of a DELETE statement. If there is no primary key, all columns are marked for read. - HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some cases (based on table->read_set) - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - HA_DUPP_POS Renamed to HA_DUPLICATE_POS - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE Set this if we should mark ALL key columns for read when when reading rows as part of a DELETE statement. In case of an update we will mark all keys for read for which key part changed value. - HA_STATS_RECORDS_IS_EXACT Set this if stats.records is exact. (This saves us some extra records() calls when optimizing COUNT(*)) - Removed table_flags() - HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if handler::records() gives an exact count() and HA_STATS_RECORDS_IS_EXACT if stats.records is exact. - HA_READ_RND_SAME Removed (no one supported this one) - Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk() - Renamed handler::dupp_pos to handler::dup_pos - Removed not used variable handler::sortkey Upper level handler changes: - ha_reset() now does some overall checks and calls ::reset() - ha_table_flags() added. This is a cached version of table_flags(). The cache is updated on engine creation time and updated on open. MySQL level changes (not obvious from the above): - DBUG_ASSERT() added to check that column usage matches what is set in the column usage bit maps. (This found a LOT of bugs in current column marking code). - In 5.1 before, all used columns was marked in read_set and only updated columns was marked in write_set. Now we only mark columns for which we need a value in read_set. - Column bitmaps are created in open_binary_frm() and open_table_from_share(). (Before this was in table.cc) - handler::table_flags() calls are replaced with handler::ha_table_flags() - For calling field->val() you must have the corresponding bit set in table->read_set. For calling field->store() you must have the corresponding bit set in table->write_set. (There are asserts in all store()/val() functions to catch wrong usage) - thd->set_query_id is renamed to thd->mark_used_columns and instead of setting this to an integer value, this has now the values: MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE Changed also all variables named 'set_query_id' to mark_used_columns. - In filesort() we now inform the handler of exactly which columns are needed doing the sort and choosing the rows. - The TABLE_SHARE object has a 'all_set' column bitmap one can use when one needs a column bitmap with all columns set. (This is used for table->use_all_columns() and other places) - The TABLE object has 3 column bitmaps: - def_read_set Default bitmap for columns to be read - def_write_set Default bitmap for columns to be written - tmp_set Can be used as a temporary bitmap when needed. The table object has also two pointer to bitmaps read_set and write_set that the handler should use to find out which columns are used in which way. - count() optimization now calls handler::records() instead of using handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true). - Added extra argument to Item::walk() to indicate if we should also traverse sub queries. - Added TABLE parameter to cp_buffer_from_ref() - Don't close tables created with CREATE ... SELECT but keep them in the table cache. (Faster usage of newly created tables). New interfaces: - table->clear_column_bitmaps() to initialize the bitmaps for tables at start of new statements. - table->column_bitmaps_set() to set up new column bitmaps and signal the handler about this. - table->column_bitmaps_set_no_signal() for some few cases where we need to setup new column bitmaps but don't signal the handler (as the handler has already been signaled about these before). Used for the momement only in opt_range.cc when doing ROR scans. - table->use_all_columns() to install a bitmap where all columns are marked as use in the read and the write set. - table->default_column_bitmaps() to install the normal read and write column bitmaps, but not signaling the handler about this. This is mainly used when creating TABLE instances. - table->mark_columns_needed_for_delete(), table->mark_columns_needed_for_delete() and table->mark_columns_needed_for_insert() to allow us to put additional columns in column usage maps if handler so requires. (The handler indicates what it neads in handler->table_flags()) - table->prepare_for_position() to allow us to tell handler that it needs to read primary key parts to be able to store them in future table->position() calls. (This replaces the table->file->ha_retrieve_all_pk function) - table->mark_auto_increment_column() to tell handler are going to update columns part of any auto_increment key. - table->mark_columns_used_by_index() to mark all columns that is part of an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow it to quickly know that it only needs to read colums that are part of the key. (The handler can also use the column map for detecting this, but simpler/faster handler can just monitor the extra() call). - table->mark_columns_used_by_index_no_reset() to in addition to other columns, also mark all columns that is used by the given key. - table->restore_column_maps_after_mark_index() to restore to default column maps after a call to table->mark_columns_used_by_index(). - New item function register_field_in_read_map(), for marking used columns in table->read_map. Used by filesort() to mark all used columns - Maintain in TABLE->merge_keys set of all keys that are used in query. (Simplices some optimization loops) - Maintain Field->part_of_key_not_clustered which is like Field->part_of_key but the field in the clustered key is not assumed to be part of all index. (used in opt_range.cc for faster loops) - dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map() tmp_use_all_columns() and tmp_restore_column_map() functions to temporally mark all columns as usable. The 'dbug_' version is primarily intended inside a handler when it wants to just call Field:store() & Field::val() functions, but don't need the column maps set for any other usage. (ie:: bitmap_is_set() is never called) - We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set. The reason for this is that if we have a column marked only for write we can't in the MySQL level know if the value changed or not. The reason this worked before was that MySQL marked all to be written columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden bug'. - open_table_from_share() does not anymore setup temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler(). (Simpler, faster code) Bugs fixed: - Column marking was not done correctly in a lot of cases. (ALTER TABLE, when using triggers, auto_increment fields etc) (Could potentially result in wrong values inserted in table handlers relying on that the old column maps or field->set_query_id was correct) Especially when it comes to triggers, there may be cases where the old code would cause lost/wrong values for NDB and/or InnoDB tables. - Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags: OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG. This allowed me to remove some wrong warnings about: "Some non-transactional changed tables couldn't be rolled back" - Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose some warnings about "Some non-transactional changed tables couldn't be rolled back") - Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table() which could cause delete_table to report random failures. - Fixed core dumps for some tests when running with --debug - Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) - slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. - If we get an duplicate row on insert, change column map to read and write all columns while retrying the operation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. - For table handler that doesn't support NULL in keys, we would give an error when creating a primary key with NULL fields, even after the fields has been automaticly converted to NOT NULL. - Creating a primary key on a SPATIAL key, would fail if field was not declared as NOT NULL. Cleanups: - Removed not used condition argument to setup_tables - Removed not needed item function reset_query_id_processor(). - Field->add_index is removed. Now this is instead maintained in (field->flags & FIELD_IN_ADD_INDEX) - Field->fieldnr is removed (use field->field_index instead) - New argument to filesort() to indicate that it should return a set of row pointers (not used columns). This allowed me to remove some references to sql_command in filesort and should also enable us to return column results in some cases where we couldn't before. - Changed column bitmap handling in opt_range.cc to be aligned with TABLE bitmap, which allowed me to use bitmap functions instead of looping over all fields to create some needed bitmaps. (Faster and smaller code) - Broke up found too long lines - Moved some variable declaration at start of function for better code readability. - Removed some not used arguments from functions. (setup_fields(), mysql_prepare_insert_check_table()) - setup_fields() now takes an enum instead of an int for marking columns usage. - For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. - Changed some constants to enum's and define's. - Using separate column read and write sets allows for easier checking of timestamp field was set by statement. - Remove calls to free_io_cache() as this is now done automaticly in ha_reset() - Don't build table->normalized_path as this is now identical to table->path (after bar's fixes to convert filenames) - Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to do comparision with the 'convert-dbug-for-diff' tool. Things left to do in 5.1: - We wrongly log failed CREATE TABLE ... SELECT in some cases when using row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result) Mats has promised to look into this. - Test that my fix for CREATE TABLE ... SELECT is indeed correct. (I added several test cases for this, but in this case it's better that someone else also tests this throughly). Lars has promosed to do this. BitKeeper/etc/ignore: added mysys/test_bitmap include/base64.h: Removed my_global.h, as this must be included first in any program include/heap.h: Added heap_reset() (Required by new handler interface) include/my_base.h: Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET). HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary include/my_bitmap.h: Remove my_pthread.h (should be included at upper level) Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp() Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void include/myisam.h: Added mi_reset() (Required by new handler interface) include/myisammrg.h: Added myrg_reset() (Required by new handler interface) include/mysql_com.h: Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/install_test_db.sh: Simplify ldata usage Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set) mysql-test/mysql-test-run.pl: Added --tmpdir=. to bootstrap mysql-test/mysql-test-run.sh: Use copy instead of INSTALL_DB for master and slave databases. (Speeds up startup time a lot!) Remove snapshot directories at startup (removes some strange warnings) mysql-test/r/binlog_row_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/r/binlog_stm_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment mysql-test/r/create.result: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/r/federated.result: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/r/func_gconcat.result: Enable some disabled tests (converted them slightly to be predictable) mysql-test/r/func_time.result: Added drop of test function mysql-test/r/innodb_mysql.result: Added tests for CREATE ... SELECT mysql-test/r/insert.result: More tests Added testing of duplicate columns in insert mysql-test/r/loaddata.result: Added testing LOAD DATA ... SET ... mysql-test/r/multi_update.result: Test multi updates and deletes using primary key and without mysql-test/r/ndb_index_unique.result: Better error message mysql-test/r/ndb_replace.result: New correct result after fixing REPLACE handling with NDB mysql-test/r/rpl_ddl.result: Now we don't get these (wrong) warnings anymore mysql-test/r/view_grant.result: Drop used views mysql-test/t/create.test: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/t/federated.test: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/t/func_gconcat.test: Enable some disabled tests (converted them slightly to be predictable) mysql-test/t/func_time.test: Added drop of test function mysql-test/t/innodb_mysql.test: Added tests for CREATE ... SELECT mysql-test/t/insert.test: More tests Added testing of duplicate columns in insert mysql-test/t/loaddata.test: Added testing LOAD DATA ... SET ... mysql-test/t/multi_update.test: Test multi updates and deletes using primary key and without mysql-test/t/view_grant.test: Drop used views mysql-test/valgrind.supp: Added supression of not needed warnings when printing stack trace mysys/base64.c: Include my_global.h first mysys/my_bitmap.c: Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy() Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström) Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed. Changed how mutex is allocated to make 'bitmap_free()' function simpler. mysys/thr_lock.c: Added 0x before thread pointers (for easier comparison of DBUG traces) sql/event.cc: Ensure 'use_all_columns()' is used for event tables Don't print warning that event table is damaged if it doesn't exists. sql/field.cc: Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set (Rest of changes are only indentation cleanups) sql/field.h: Removed Field->query_id (replaced by table->read_set and table->write_set) Removed Field->fieldnr (use Field->field_index instead) Removed Field->add_index (Use Field->flags instead) Add Field->part_of_key_not_clustered (for usage in opt_range.cc) sql/filesort.cc: Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set. This allowed me to remove checking of sql_command. Create a temporary column bitmap for fields that are used by the sorting process. Use column bitmaps instead of query_id sql/ha_berkeley.cc: Update to 'newer' table handler interface sql/ha_berkeley.h: Update to 'newer' table handler interface sql/ha_federated.cc: Update to 'newer' table handler interface Only read columns that are needed from remote server. In case of eq ranges, don't generate two conditions in the WHERE clause (this can still be optimized, but would require a bigger code change) Use 'simpler to use' XXXX_LEN' macros A bit simpler logic in ::write_row() when creating statements. In update, only include test of fields actually read. (This greatly simplifies the queries sent by the federated engine) Similar changes done for delete_row() sql/ha_federated.h: Update to 'newer' table handler interface Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE sql/ha_heap.cc: Update to 'newer' table handler interface sql/ha_heap.h: Update to 'newer' table handler interface sql/ha_innodb.cc: Update to 'newer' table handler interface - Update innobase_create_handler() to new interface - Removed HA_NOT_EXACT_COUNT (not needed) - Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - Prefixed base status variables with 'stats' - Use table column bitmaps instead of ha_get_bit_in_read_set() - Added ::reset(), with code from ::extra(HA_EXTRA_RESET) - Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as the table->read_set and table->write_set bitmaps now are accurate sql/ha_innodb.h: Update to 'newer' table handler interface - table_flags are now ulonglong - Added reset() method - Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns. - Made build_template() a class function to be able to easier access class variables sql/ha_myisam.cc: Update to 'newer' table handler interface sql/ha_myisam.h: Update to 'newer' table handler interface sql/ha_myisammrg.cc: Update to 'newer' table handler interface sql/ha_myisammrg.h: Update to 'newer' table handler interface sql/ha_ndbcluster.cc: Update to 'newer' table handler interface Fixed use_blob_value() to be accurate In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map Correct dumping of field data with DBUG_DUMP Prefix addresses in DBUG_PRINT with 0x Fixed usage of not initialized memory Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index. sql/ha_ndbcluster.h: Update to 'newer' table handler interface sql/ha_ndbcluster_binlog.cc: Mark usage of all columns in ndbcluster binlog tables false -> FALSE, true -> TRUE Use table->s->all_set instead of creating a temporary bitmap. sql/ha_partition.cc: Update to 'newer' table handler interface Added memroot to initialise_partitions() and related functions to get faster memory allocation. partition_create_handler() is now responsible for initialisation of the partition object Some trivial optimizations and indentation fixes Ensure that table_flags() are up to date Removed documentation for removed HA_EXTRA flags Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance' sql/ha_partition.h: Update to 'newer' table handler interface sql/handler.cc: create_xxx handler now takes MEMROOT as an argument to simplify memory allocation. Much simpler get_new_handler() (Initialization of the object is now handled by the create method for the engine) Moved all allocation of bitmap handling to the TABLE object (in table.cc) Added column_bitmaps_signal() to signal column usage changes. Changed binlog_log_row() to use the exiusting all_set bitmap in the table object. Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset() Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row sql/handler.h: Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME HA_DUPP_POS -> HA_DUPLICATE_POS HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records() HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION Added future row type 'ROW_TYPE_PAGES' Added MEM_ROOT to handlerton 'create' function Added ha_statistics, a structure for all status variable in the base handler class. Moved all status variables in the handler class into a stats structs to improve readability. ha_table_flags() is now a cached (not virtual) version of table_flags() reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own. Renamed dupp_ref to dup_ref Renamed not used handler::sortkey Moved read_set and write_set to TABLE structure handler::init() function added for cacheing of virtual constants from engine. sql/item.cc: Added register_field_in_read_map() for marking used columns in expression. This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting. Initalize value.cs_info.character_set_client to fix core dump bug with --debug set_query_id -> mark_used_columns Mark used columns in read_set OR write_set. sql/item.h: Removed reset_query_id_processor() as it's not needed anymore. Added register_field_in_read_map() Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_cmpfunc.cc: Temporary mark used columns to be read/writable Update Item::walk to new interface sql/item_cmpfunc.h: Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_func.cc: Update Item::walk() to new interface table_flags() -> ha_table_flags() sql/item_func.h: Update Item::walk() to new interface sql/item_row.cc: Update Item::walk() to new interface sql/item_row.h: Update Item::walk() to new interface sql/item_strfunc.h: Update Item::walk() to new interface sql/item_subselect.cc: Added Item_subselect::walk() (It was a bug it was missing before. Not sure what kind of bugs this could have caused) sql/item_subselect.h: Update Item::walk() to new interface sql/item_sum.cc: Update Item::walk() to new interface Updates for new handler interace sql/item_sum.h: Update Item::walk() to new interface sql/key.cc: Updates for new handler interace sql/log.cc: Mark all columns used for log tables Split options flag Ensured that second argument to trans_register_ha is a bool sql/log_event.cc: Fixed comments to be withing 79 characters Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings Updates for new handler interface Use 0x%lx instead of %p (portability problem) sql/mysql_priv.h: Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback Removed not used 'conds' argument to setup_tables sql/mysqld.cc: Indentation fixes and removed old comment sql/opt_range.cc: Update to new handler and bitmap interface. Fixed calls to cp_buffer_from_ref() and walk() (new argument). Create new temporary bitmaps for ror scans. (Needed because of handler changes and to get more accurate column bitmaps than before) Remove not needed file->ha_reset() call before file->close(). Some trivial optimization and indentation fixes. Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts. Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record. This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling. (This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans) Optimized bitmap handling in ror scans: - Start bitmap at position 0, not 1 - Use same bitmap size as in TABLE - Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table sql/opt_range.h: Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan Added temporary column bitmaps used in ROR scans sql/opt_sum.cc: Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set. sql/protocol.cc: We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user sql/records.cc: Updates for new handler interface sql/set_var.cc: Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags sql/share/errmsg.txt: Fixed wrong sql/sp.cc: Mark that we are using all columns for the proc table Update call to setup_tables() to use new prototype sql/sp_head.cc: Removed QQ comment sql/spatial.cc: Removed wrong QQ comment sql/sql_acl.cc: Mark that we need all columns for acl tables Supply memroot to some 'new' calls. Indentation fixes sql/sql_base.cc: set_query_id removed Ensure we call ha_reset() at end of each statement Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set) Fixed marking of some columns that was not proplerly marked before Maintain in TABLE->merge_keys set of all keys that are used in some way Removed not used 'conds' argument from setup_tables() Remove not used setting of 'dupp_field' in insert_fields() Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) sql/sql_bitmap.h: Added is_overlapping() sql/sql_class.cc: Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. set_query_id -> mark_used_columns Simpler variable usage in pack_row() (cleanup) Moved some variable declartion at start of function for better code readability sql/sql_class.h: Added enum_mark_columns Updated comments Renamed dupp_field -> dup_field Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE. (This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables) sql/sql_delete.cc: Updates to new handler interface Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires. Call table->prepare_for_position() to tell handler that we are going to call ha_position(). Removed call to free_io_cache(). (io_cache is now removed in ha_reset()). Fixed calls to setup_tables() sql/sql_do.cc: Update call to setup_fields() sql/sql_handler.cc: Tell handler tables to always read all columns. Use temporary column map when storing value in field for later index usage sql/sql_help.cc: Makr all used fields to be read Update call to setup_fields() sql/sql_insert.cc: Tell handler we are going to update the auto_increment column dupp_field -> dup_field Set column usage bits for timestamp field. Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column() Removed not used argument from mysql_prepare_insert_check_table(). If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. Setup new bitmaps for delayed insert rows Remove reseting of next_number_fields as it will be reset on next call to handler_insert() Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE. The issue was that one should not to reset this flag as it may be set by a previous statement. The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional. I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done) Don't close tables created with CREATE ... SELECT but keep them in the table cache. Moved out MY_HOOKS from inside function (better readability) sql/sql_load.cc: Update to use new handler and column marking interface Update using setup_tables() sql/sql_olap.cc: Update calls to setup_tables Use enums instead of constants to setup_fields() sql/sql_parse.cc: Handle OPTION_KEEP_LOG: - Set it on CREATE TEMPORARY TABLE / DROP TABLE - Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset - Don't set it for CREATE ... SELECT (this is handled in select_create class) Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset. If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands sql/sql_partition.cc: Update walk() usage Trivial indentation fixes sql/sql_plugin.cc: Mark all columns as used for plugins sql/sql_prepare.cc: Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly) Updates for new handler interface Update calls to setup_fields() sql/sql_repl.cc: Indentation fixes sql/sql_select.cc: Update call to setup_tables() and setup_fields() Remove some old disabled code Update to new hadler interface Indentation cleanups Added column bitmaps for temporary tables. Remove updating of the removed slots in the Field class Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps) For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. sql/sql_select.h: Indentaition fixes. Install temporary column usage maps when needed Added TABLE element to cp_buffer_from_ref() sql/sql_show.cc: Update to new handler interface Mark all columns used for internal tables. Style fixes. Added support for 'future' ROW_TYPE_PAGES. Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly. sql/sql_table.cc: Update to new handler interface Simple my_snprintf -> strmake() Changed some constants to defines Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL) Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX Mark all columns as used for ALTER TABLE Style fixes Update call to filesort() sql/sql_trigger.h: Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in. sql/sql_udf.cc: Mark all columns as used for udf system table. sql/sql_union.cc: Update call to walk() Update to new handler interface sql/sql_update.cc: Remove query_id argument from compare_record() Use column bitmaps instead of query_id. We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value. Update call to setup_fields() Using separate column read and write sets allows for easier checking of timestamp field was set by statement. Removed call to free_io_cache() as this is now done in ha_reset() Call table->mark_columns_needed_for_update() and table->prepare_for_position() Style fixes sql/sql_view.cc: Style fixes sql/table.cc: Remove implicitely include 'errno.h' Remove code for building normalized path, as this is now identical to 'path' Remove field->fieldnr Added update of field->part_of_key_not_clustered() Create column bitmaps in TABLE and TABLE_SHARE Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler() Update to new handler interface Update call to walk() Added new functions: - st_table::clear_column_bitmaps() - st_table::prepare_for_position() - st_table::mark_columns_used_by_index() - st_table::restore_column_maps_after_mark_index() - st_table::mark_columns_used_by_index_no_reset() - st_table::mark_auto_increment_column() - st_table::mark_columns_needed_for_delete() - st_table::mark_columns_needed_for_update() - st_table::mark_columns_needed_for_insert() sql/table.h: Moved column usage bitmaps from handler to TABLE Added to TABLE_SHARE all_set and column_bitmap_size Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set. Declared all new table column bitmap functions Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps() Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val(). sql/tztime.cc: Mark all columns as used for timezone tables storage/archive/ha_archive.cc: Update to new handler interface storage/archive/ha_archive.h: Update to new handler interface storage/blackhole/ha_blackhole.cc: Update to new handler interface storage/blackhole/ha_blackhole.h: Update to new handler interface removed not needed flag HA_DUPP_POS storage/csv/ha_tina.cc: Update to new handler interface storage/csv/ha_tina.h: Update to new handler interface storage/example/ha_example.cc: Update to new handler interface storage/example/ha_example.h: Update to new handler interface storage/heap/hp_extra.c: Added heap_reset() (Required by new handler interface) storage/heap/hp_test2.c: Use heap_reset() storage/myisam/ft_boolean_search.c: Fixed compiler warning storage/myisam/mi_extra.c: Added mi_reset() (Required by new handler interface) storage/myisam/mi_search.c: Fixed DBUG_PRINT messages to use 0x%lx instead of %lx storage/myisam/mi_test2.c: Use mi_reset() storage/myisam/myisampack.c: Use mi_reset() storage/myisammrg/myrg_extra.c: Added myrg_reset() (Required by new handler interface) unittest/mysys/base64.t.c: Include my_global.h Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
{
if ((*order->item)->walk(processor, walk_subquery, argument))
return 1;
}
Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. One somewhat major source of strict-aliasing violations and related warnings is the SQL_LIST structure. For example, consider its member function `link_in_list` which takes a pointer to pointer of type T (any type) as a pointer to pointer to unsigned char. Dereferencing this pointer, which is done to reset the next field, violates strict-aliasing rules and might cause problems for surrounding code that uses the next field of the object being added to the list. The solution is to use templates to parametrize the SQL_LIST structure in order to deference the pointers with compatible types. As a side bonus, it becomes possible to remove quite a few casts related to acessing data members of SQL_LIST. sql/handler.h: Use the appropriate template type argument. sql/item.cc: Remove now-unnecessary cast. sql/item_subselect.cc: Remove now-unnecessary casts. sql/item_sum.cc: Use the appropriate template type argument. Remove now-unnecessary cast. sql/mysql_priv.h: Move SQL_LIST structure to sql_list.h Use the appropriate template type argument. sql/sp.cc: Remove now-unnecessary casts. sql/sql_delete.cc: Use the appropriate template type argument. Remove now-unnecessary casts. sql/sql_derived.cc: Remove now-unnecessary casts. sql/sql_lex.cc: Remove now-unnecessary casts. sql/sql_lex.h: SQL_LIST now takes a template type argument which must match the type of the elements of the list. Use forward declaration when the type is not available, it is used in pointers anyway. sql/sql_list.h: Rename SQL_LIST to SQL_I_List. The template parameter is the type of object that is stored in the list. sql/sql_olap.cc: Remove now-unnecessary casts. sql/sql_parse.cc: Remove now-unnecessary casts. sql/sql_prepare.cc: Remove now-unnecessary casts. sql/sql_select.cc: Remove now-unnecessary casts. sql/sql_show.cc: Remove now-unnecessary casts. sql/sql_table.cc: Remove now-unnecessary casts. sql/sql_trigger.cc: Remove now-unnecessary casts. sql/sql_union.cc: Remove now-unnecessary casts. sql/sql_update.cc: Remove now-unnecessary casts. sql/sql_view.cc: Remove now-unnecessary casts. sql/sql_yacc.yy: Remove now-unnecessary casts. storage/myisammrg/ha_myisammrg.cc: Remove now-unnecessary casts.
2010-06-10 22:45:22 +02:00
for (order= lex->group_list.first ; order; order= order->next)
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes Changes that requires code changes in other code of other storage engines. (Note that all changes are very straightforward and one should find all issues by compiling a --debug build and fixing all compiler errors and all asserts in field.cc while running the test suite), - New optional handler function introduced: reset() This is called after every DML statement to make it easy for a handler to statement specific cleanups. (The only case it's not called is if force the file to be closed) - handler::extra(HA_EXTRA_RESET) is removed. Code that was there before should be moved to handler::reset() - table->read_set contains a bitmap over all columns that are needed in the query. read_row() and similar functions only needs to read these columns - table->write_set contains a bitmap over all columns that will be updated in the query. write_row() and update_row() only needs to update these columns. The above bitmaps should now be up to date in all context (including ALTER TABLE, filesort()). The handler is informed of any changes to the bitmap after fix_fields() by calling the virtual function handler::column_bitmaps_signal(). If the handler does caching of these bitmaps (instead of using table->read_set, table->write_set), it should redo the caching in this code. as the signal() may be sent several times, it's probably best to set a variable in the signal and redo the caching on read_row() / write_row() if the variable was set. - Removed the read_set and write_set bitmap objects from the handler class - Removed all column bit handling functions from the handler class. (Now one instead uses the normal bitmap functions in my_bitmap.c instead of handler dedicated bitmap functions) - field->query_id is removed. One should instead instead check table->read_set and table->write_set if a field is used in the query. - handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now instead use table->read_set to check for which columns to retrieve. - If a handler needs to call Field->val() or Field->store() on columns that are not used in the query, one should install a temporary all-columns-used map while doing so. For this, we provide the following functions: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); field->val(); dbug_tmp_restore_column_map(table->read_set, old_map); and similar for the write map: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); field->val(); dbug_tmp_restore_column_map(table->write_set, old_map); If this is not done, you will sooner or later hit a DBUG_ASSERT in the field store() / val() functions. (For not DBUG binaries, the dbug_tmp_restore_column_map() and dbug_tmp_restore_column_map() are inline dummy functions and should be optimized away be the compiler). - If one needs to temporary set the column map for all binaries (and not just to avoid the DBUG_ASSERT() in the Field::store() / Field::val() methods) one should use the functions tmp_use_all_columns() and tmp_restore_column_map() instead of the above dbug_ variants. - All 'status' fields in the handler base class (like records, data_file_length etc) are now stored in a 'stats' struct. This makes it easier to know what status variables are provided by the base handler. This requires some trivial variable names in the extra() function. - New virtual function handler::records(). This is called to optimize COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true. (stats.records is not supposed to be an exact value. It's only has to be 'reasonable enough' for the optimizer to be able to choose a good optimization path). - Non virtual handler::init() function added for caching of virtual constants from engine. - Removed has_transactions() virtual method. Now one should instead return HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support transactions. - The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument that is to be used with 'new handler_name()' to allocate the handler in the right area. The xxxx_create_handler() function is also responsible for any initialization of the object before returning. For example, one should change: static handler *myisam_create_handler(TABLE_SHARE *table) { return new ha_myisam(table); } -> static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { return new (mem_root) ha_myisam(table); } - New optional virtual function: use_hidden_primary_key(). This is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined but we don't have a primary key. This allows the handler to take precisions in remembering any hidden primary key to able to update/delete any found row. The default handler marks all columns to be read. - handler::table_flags() now returns a ulonglong (to allow for more flags). - New/changed table_flags() - HA_HAS_RECORDS Set if ::records() is supported - HA_NO_TRANSACTIONS Set if engine doesn't support transactions - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE Set if we should mark all primary key columns for read when reading rows as part of a DELETE statement. If there is no primary key, all columns are marked for read. - HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some cases (based on table->read_set) - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - HA_DUPP_POS Renamed to HA_DUPLICATE_POS - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE Set this if we should mark ALL key columns for read when when reading rows as part of a DELETE statement. In case of an update we will mark all keys for read for which key part changed value. - HA_STATS_RECORDS_IS_EXACT Set this if stats.records is exact. (This saves us some extra records() calls when optimizing COUNT(*)) - Removed table_flags() - HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if handler::records() gives an exact count() and HA_STATS_RECORDS_IS_EXACT if stats.records is exact. - HA_READ_RND_SAME Removed (no one supported this one) - Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk() - Renamed handler::dupp_pos to handler::dup_pos - Removed not used variable handler::sortkey Upper level handler changes: - ha_reset() now does some overall checks and calls ::reset() - ha_table_flags() added. This is a cached version of table_flags(). The cache is updated on engine creation time and updated on open. MySQL level changes (not obvious from the above): - DBUG_ASSERT() added to check that column usage matches what is set in the column usage bit maps. (This found a LOT of bugs in current column marking code). - In 5.1 before, all used columns was marked in read_set and only updated columns was marked in write_set. Now we only mark columns for which we need a value in read_set. - Column bitmaps are created in open_binary_frm() and open_table_from_share(). (Before this was in table.cc) - handler::table_flags() calls are replaced with handler::ha_table_flags() - For calling field->val() you must have the corresponding bit set in table->read_set. For calling field->store() you must have the corresponding bit set in table->write_set. (There are asserts in all store()/val() functions to catch wrong usage) - thd->set_query_id is renamed to thd->mark_used_columns and instead of setting this to an integer value, this has now the values: MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE Changed also all variables named 'set_query_id' to mark_used_columns. - In filesort() we now inform the handler of exactly which columns are needed doing the sort and choosing the rows. - The TABLE_SHARE object has a 'all_set' column bitmap one can use when one needs a column bitmap with all columns set. (This is used for table->use_all_columns() and other places) - The TABLE object has 3 column bitmaps: - def_read_set Default bitmap for columns to be read - def_write_set Default bitmap for columns to be written - tmp_set Can be used as a temporary bitmap when needed. The table object has also two pointer to bitmaps read_set and write_set that the handler should use to find out which columns are used in which way. - count() optimization now calls handler::records() instead of using handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true). - Added extra argument to Item::walk() to indicate if we should also traverse sub queries. - Added TABLE parameter to cp_buffer_from_ref() - Don't close tables created with CREATE ... SELECT but keep them in the table cache. (Faster usage of newly created tables). New interfaces: - table->clear_column_bitmaps() to initialize the bitmaps for tables at start of new statements. - table->column_bitmaps_set() to set up new column bitmaps and signal the handler about this. - table->column_bitmaps_set_no_signal() for some few cases where we need to setup new column bitmaps but don't signal the handler (as the handler has already been signaled about these before). Used for the momement only in opt_range.cc when doing ROR scans. - table->use_all_columns() to install a bitmap where all columns are marked as use in the read and the write set. - table->default_column_bitmaps() to install the normal read and write column bitmaps, but not signaling the handler about this. This is mainly used when creating TABLE instances. - table->mark_columns_needed_for_delete(), table->mark_columns_needed_for_delete() and table->mark_columns_needed_for_insert() to allow us to put additional columns in column usage maps if handler so requires. (The handler indicates what it neads in handler->table_flags()) - table->prepare_for_position() to allow us to tell handler that it needs to read primary key parts to be able to store them in future table->position() calls. (This replaces the table->file->ha_retrieve_all_pk function) - table->mark_auto_increment_column() to tell handler are going to update columns part of any auto_increment key. - table->mark_columns_used_by_index() to mark all columns that is part of an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow it to quickly know that it only needs to read colums that are part of the key. (The handler can also use the column map for detecting this, but simpler/faster handler can just monitor the extra() call). - table->mark_columns_used_by_index_no_reset() to in addition to other columns, also mark all columns that is used by the given key. - table->restore_column_maps_after_mark_index() to restore to default column maps after a call to table->mark_columns_used_by_index(). - New item function register_field_in_read_map(), for marking used columns in table->read_map. Used by filesort() to mark all used columns - Maintain in TABLE->merge_keys set of all keys that are used in query. (Simplices some optimization loops) - Maintain Field->part_of_key_not_clustered which is like Field->part_of_key but the field in the clustered key is not assumed to be part of all index. (used in opt_range.cc for faster loops) - dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map() tmp_use_all_columns() and tmp_restore_column_map() functions to temporally mark all columns as usable. The 'dbug_' version is primarily intended inside a handler when it wants to just call Field:store() & Field::val() functions, but don't need the column maps set for any other usage. (ie:: bitmap_is_set() is never called) - We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set. The reason for this is that if we have a column marked only for write we can't in the MySQL level know if the value changed or not. The reason this worked before was that MySQL marked all to be written columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden bug'. - open_table_from_share() does not anymore setup temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler(). (Simpler, faster code) Bugs fixed: - Column marking was not done correctly in a lot of cases. (ALTER TABLE, when using triggers, auto_increment fields etc) (Could potentially result in wrong values inserted in table handlers relying on that the old column maps or field->set_query_id was correct) Especially when it comes to triggers, there may be cases where the old code would cause lost/wrong values for NDB and/or InnoDB tables. - Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags: OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG. This allowed me to remove some wrong warnings about: "Some non-transactional changed tables couldn't be rolled back" - Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose some warnings about "Some non-transactional changed tables couldn't be rolled back") - Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table() which could cause delete_table to report random failures. - Fixed core dumps for some tests when running with --debug - Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) - slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. - If we get an duplicate row on insert, change column map to read and write all columns while retrying the operation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. - For table handler that doesn't support NULL in keys, we would give an error when creating a primary key with NULL fields, even after the fields has been automaticly converted to NOT NULL. - Creating a primary key on a SPATIAL key, would fail if field was not declared as NOT NULL. Cleanups: - Removed not used condition argument to setup_tables - Removed not needed item function reset_query_id_processor(). - Field->add_index is removed. Now this is instead maintained in (field->flags & FIELD_IN_ADD_INDEX) - Field->fieldnr is removed (use field->field_index instead) - New argument to filesort() to indicate that it should return a set of row pointers (not used columns). This allowed me to remove some references to sql_command in filesort and should also enable us to return column results in some cases where we couldn't before. - Changed column bitmap handling in opt_range.cc to be aligned with TABLE bitmap, which allowed me to use bitmap functions instead of looping over all fields to create some needed bitmaps. (Faster and smaller code) - Broke up found too long lines - Moved some variable declaration at start of function for better code readability. - Removed some not used arguments from functions. (setup_fields(), mysql_prepare_insert_check_table()) - setup_fields() now takes an enum instead of an int for marking columns usage. - For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. - Changed some constants to enum's and define's. - Using separate column read and write sets allows for easier checking of timestamp field was set by statement. - Remove calls to free_io_cache() as this is now done automaticly in ha_reset() - Don't build table->normalized_path as this is now identical to table->path (after bar's fixes to convert filenames) - Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to do comparision with the 'convert-dbug-for-diff' tool. Things left to do in 5.1: - We wrongly log failed CREATE TABLE ... SELECT in some cases when using row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result) Mats has promised to look into this. - Test that my fix for CREATE TABLE ... SELECT is indeed correct. (I added several test cases for this, but in this case it's better that someone else also tests this throughly). Lars has promosed to do this. BitKeeper/etc/ignore: added mysys/test_bitmap include/base64.h: Removed my_global.h, as this must be included first in any program include/heap.h: Added heap_reset() (Required by new handler interface) include/my_base.h: Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET). HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary include/my_bitmap.h: Remove my_pthread.h (should be included at upper level) Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp() Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void include/myisam.h: Added mi_reset() (Required by new handler interface) include/myisammrg.h: Added myrg_reset() (Required by new handler interface) include/mysql_com.h: Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/install_test_db.sh: Simplify ldata usage Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set) mysql-test/mysql-test-run.pl: Added --tmpdir=. to bootstrap mysql-test/mysql-test-run.sh: Use copy instead of INSTALL_DB for master and slave databases. (Speeds up startup time a lot!) Remove snapshot directories at startup (removes some strange warnings) mysql-test/r/binlog_row_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/r/binlog_stm_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment mysql-test/r/create.result: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/r/federated.result: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/r/func_gconcat.result: Enable some disabled tests (converted them slightly to be predictable) mysql-test/r/func_time.result: Added drop of test function mysql-test/r/innodb_mysql.result: Added tests for CREATE ... SELECT mysql-test/r/insert.result: More tests Added testing of duplicate columns in insert mysql-test/r/loaddata.result: Added testing LOAD DATA ... SET ... mysql-test/r/multi_update.result: Test multi updates and deletes using primary key and without mysql-test/r/ndb_index_unique.result: Better error message mysql-test/r/ndb_replace.result: New correct result after fixing REPLACE handling with NDB mysql-test/r/rpl_ddl.result: Now we don't get these (wrong) warnings anymore mysql-test/r/view_grant.result: Drop used views mysql-test/t/create.test: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/t/federated.test: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/t/func_gconcat.test: Enable some disabled tests (converted them slightly to be predictable) mysql-test/t/func_time.test: Added drop of test function mysql-test/t/innodb_mysql.test: Added tests for CREATE ... SELECT mysql-test/t/insert.test: More tests Added testing of duplicate columns in insert mysql-test/t/loaddata.test: Added testing LOAD DATA ... SET ... mysql-test/t/multi_update.test: Test multi updates and deletes using primary key and without mysql-test/t/view_grant.test: Drop used views mysql-test/valgrind.supp: Added supression of not needed warnings when printing stack trace mysys/base64.c: Include my_global.h first mysys/my_bitmap.c: Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy() Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström) Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed. Changed how mutex is allocated to make 'bitmap_free()' function simpler. mysys/thr_lock.c: Added 0x before thread pointers (for easier comparison of DBUG traces) sql/event.cc: Ensure 'use_all_columns()' is used for event tables Don't print warning that event table is damaged if it doesn't exists. sql/field.cc: Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set (Rest of changes are only indentation cleanups) sql/field.h: Removed Field->query_id (replaced by table->read_set and table->write_set) Removed Field->fieldnr (use Field->field_index instead) Removed Field->add_index (Use Field->flags instead) Add Field->part_of_key_not_clustered (for usage in opt_range.cc) sql/filesort.cc: Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set. This allowed me to remove checking of sql_command. Create a temporary column bitmap for fields that are used by the sorting process. Use column bitmaps instead of query_id sql/ha_berkeley.cc: Update to 'newer' table handler interface sql/ha_berkeley.h: Update to 'newer' table handler interface sql/ha_federated.cc: Update to 'newer' table handler interface Only read columns that are needed from remote server. In case of eq ranges, don't generate two conditions in the WHERE clause (this can still be optimized, but would require a bigger code change) Use 'simpler to use' XXXX_LEN' macros A bit simpler logic in ::write_row() when creating statements. In update, only include test of fields actually read. (This greatly simplifies the queries sent by the federated engine) Similar changes done for delete_row() sql/ha_federated.h: Update to 'newer' table handler interface Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE sql/ha_heap.cc: Update to 'newer' table handler interface sql/ha_heap.h: Update to 'newer' table handler interface sql/ha_innodb.cc: Update to 'newer' table handler interface - Update innobase_create_handler() to new interface - Removed HA_NOT_EXACT_COUNT (not needed) - Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - Prefixed base status variables with 'stats' - Use table column bitmaps instead of ha_get_bit_in_read_set() - Added ::reset(), with code from ::extra(HA_EXTRA_RESET) - Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as the table->read_set and table->write_set bitmaps now are accurate sql/ha_innodb.h: Update to 'newer' table handler interface - table_flags are now ulonglong - Added reset() method - Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns. - Made build_template() a class function to be able to easier access class variables sql/ha_myisam.cc: Update to 'newer' table handler interface sql/ha_myisam.h: Update to 'newer' table handler interface sql/ha_myisammrg.cc: Update to 'newer' table handler interface sql/ha_myisammrg.h: Update to 'newer' table handler interface sql/ha_ndbcluster.cc: Update to 'newer' table handler interface Fixed use_blob_value() to be accurate In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map Correct dumping of field data with DBUG_DUMP Prefix addresses in DBUG_PRINT with 0x Fixed usage of not initialized memory Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index. sql/ha_ndbcluster.h: Update to 'newer' table handler interface sql/ha_ndbcluster_binlog.cc: Mark usage of all columns in ndbcluster binlog tables false -> FALSE, true -> TRUE Use table->s->all_set instead of creating a temporary bitmap. sql/ha_partition.cc: Update to 'newer' table handler interface Added memroot to initialise_partitions() and related functions to get faster memory allocation. partition_create_handler() is now responsible for initialisation of the partition object Some trivial optimizations and indentation fixes Ensure that table_flags() are up to date Removed documentation for removed HA_EXTRA flags Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance' sql/ha_partition.h: Update to 'newer' table handler interface sql/handler.cc: create_xxx handler now takes MEMROOT as an argument to simplify memory allocation. Much simpler get_new_handler() (Initialization of the object is now handled by the create method for the engine) Moved all allocation of bitmap handling to the TABLE object (in table.cc) Added column_bitmaps_signal() to signal column usage changes. Changed binlog_log_row() to use the exiusting all_set bitmap in the table object. Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset() Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row sql/handler.h: Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME HA_DUPP_POS -> HA_DUPLICATE_POS HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records() HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION Added future row type 'ROW_TYPE_PAGES' Added MEM_ROOT to handlerton 'create' function Added ha_statistics, a structure for all status variable in the base handler class. Moved all status variables in the handler class into a stats structs to improve readability. ha_table_flags() is now a cached (not virtual) version of table_flags() reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own. Renamed dupp_ref to dup_ref Renamed not used handler::sortkey Moved read_set and write_set to TABLE structure handler::init() function added for cacheing of virtual constants from engine. sql/item.cc: Added register_field_in_read_map() for marking used columns in expression. This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting. Initalize value.cs_info.character_set_client to fix core dump bug with --debug set_query_id -> mark_used_columns Mark used columns in read_set OR write_set. sql/item.h: Removed reset_query_id_processor() as it's not needed anymore. Added register_field_in_read_map() Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_cmpfunc.cc: Temporary mark used columns to be read/writable Update Item::walk to new interface sql/item_cmpfunc.h: Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_func.cc: Update Item::walk() to new interface table_flags() -> ha_table_flags() sql/item_func.h: Update Item::walk() to new interface sql/item_row.cc: Update Item::walk() to new interface sql/item_row.h: Update Item::walk() to new interface sql/item_strfunc.h: Update Item::walk() to new interface sql/item_subselect.cc: Added Item_subselect::walk() (It was a bug it was missing before. Not sure what kind of bugs this could have caused) sql/item_subselect.h: Update Item::walk() to new interface sql/item_sum.cc: Update Item::walk() to new interface Updates for new handler interace sql/item_sum.h: Update Item::walk() to new interface sql/key.cc: Updates for new handler interace sql/log.cc: Mark all columns used for log tables Split options flag Ensured that second argument to trans_register_ha is a bool sql/log_event.cc: Fixed comments to be withing 79 characters Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings Updates for new handler interface Use 0x%lx instead of %p (portability problem) sql/mysql_priv.h: Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback Removed not used 'conds' argument to setup_tables sql/mysqld.cc: Indentation fixes and removed old comment sql/opt_range.cc: Update to new handler and bitmap interface. Fixed calls to cp_buffer_from_ref() and walk() (new argument). Create new temporary bitmaps for ror scans. (Needed because of handler changes and to get more accurate column bitmaps than before) Remove not needed file->ha_reset() call before file->close(). Some trivial optimization and indentation fixes. Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts. Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record. This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling. (This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans) Optimized bitmap handling in ror scans: - Start bitmap at position 0, not 1 - Use same bitmap size as in TABLE - Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table sql/opt_range.h: Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan Added temporary column bitmaps used in ROR scans sql/opt_sum.cc: Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set. sql/protocol.cc: We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user sql/records.cc: Updates for new handler interface sql/set_var.cc: Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags sql/share/errmsg.txt: Fixed wrong sql/sp.cc: Mark that we are using all columns for the proc table Update call to setup_tables() to use new prototype sql/sp_head.cc: Removed QQ comment sql/spatial.cc: Removed wrong QQ comment sql/sql_acl.cc: Mark that we need all columns for acl tables Supply memroot to some 'new' calls. Indentation fixes sql/sql_base.cc: set_query_id removed Ensure we call ha_reset() at end of each statement Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set) Fixed marking of some columns that was not proplerly marked before Maintain in TABLE->merge_keys set of all keys that are used in some way Removed not used 'conds' argument from setup_tables() Remove not used setting of 'dupp_field' in insert_fields() Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) sql/sql_bitmap.h: Added is_overlapping() sql/sql_class.cc: Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. set_query_id -> mark_used_columns Simpler variable usage in pack_row() (cleanup) Moved some variable declartion at start of function for better code readability sql/sql_class.h: Added enum_mark_columns Updated comments Renamed dupp_field -> dup_field Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE. (This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables) sql/sql_delete.cc: Updates to new handler interface Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires. Call table->prepare_for_position() to tell handler that we are going to call ha_position(). Removed call to free_io_cache(). (io_cache is now removed in ha_reset()). Fixed calls to setup_tables() sql/sql_do.cc: Update call to setup_fields() sql/sql_handler.cc: Tell handler tables to always read all columns. Use temporary column map when storing value in field for later index usage sql/sql_help.cc: Makr all used fields to be read Update call to setup_fields() sql/sql_insert.cc: Tell handler we are going to update the auto_increment column dupp_field -> dup_field Set column usage bits for timestamp field. Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column() Removed not used argument from mysql_prepare_insert_check_table(). If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. Setup new bitmaps for delayed insert rows Remove reseting of next_number_fields as it will be reset on next call to handler_insert() Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE. The issue was that one should not to reset this flag as it may be set by a previous statement. The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional. I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done) Don't close tables created with CREATE ... SELECT but keep them in the table cache. Moved out MY_HOOKS from inside function (better readability) sql/sql_load.cc: Update to use new handler and column marking interface Update using setup_tables() sql/sql_olap.cc: Update calls to setup_tables Use enums instead of constants to setup_fields() sql/sql_parse.cc: Handle OPTION_KEEP_LOG: - Set it on CREATE TEMPORARY TABLE / DROP TABLE - Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset - Don't set it for CREATE ... SELECT (this is handled in select_create class) Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset. If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands sql/sql_partition.cc: Update walk() usage Trivial indentation fixes sql/sql_plugin.cc: Mark all columns as used for plugins sql/sql_prepare.cc: Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly) Updates for new handler interface Update calls to setup_fields() sql/sql_repl.cc: Indentation fixes sql/sql_select.cc: Update call to setup_tables() and setup_fields() Remove some old disabled code Update to new hadler interface Indentation cleanups Added column bitmaps for temporary tables. Remove updating of the removed slots in the Field class Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps) For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. sql/sql_select.h: Indentaition fixes. Install temporary column usage maps when needed Added TABLE element to cp_buffer_from_ref() sql/sql_show.cc: Update to new handler interface Mark all columns used for internal tables. Style fixes. Added support for 'future' ROW_TYPE_PAGES. Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly. sql/sql_table.cc: Update to new handler interface Simple my_snprintf -> strmake() Changed some constants to defines Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL) Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX Mark all columns as used for ALTER TABLE Style fixes Update call to filesort() sql/sql_trigger.h: Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in. sql/sql_udf.cc: Mark all columns as used for udf system table. sql/sql_union.cc: Update call to walk() Update to new handler interface sql/sql_update.cc: Remove query_id argument from compare_record() Use column bitmaps instead of query_id. We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value. Update call to setup_fields() Using separate column read and write sets allows for easier checking of timestamp field was set by statement. Removed call to free_io_cache() as this is now done in ha_reset() Call table->mark_columns_needed_for_update() and table->prepare_for_position() Style fixes sql/sql_view.cc: Style fixes sql/table.cc: Remove implicitely include 'errno.h' Remove code for building normalized path, as this is now identical to 'path' Remove field->fieldnr Added update of field->part_of_key_not_clustered() Create column bitmaps in TABLE and TABLE_SHARE Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler() Update to new handler interface Update call to walk() Added new functions: - st_table::clear_column_bitmaps() - st_table::prepare_for_position() - st_table::mark_columns_used_by_index() - st_table::restore_column_maps_after_mark_index() - st_table::mark_columns_used_by_index_no_reset() - st_table::mark_auto_increment_column() - st_table::mark_columns_needed_for_delete() - st_table::mark_columns_needed_for_update() - st_table::mark_columns_needed_for_insert() sql/table.h: Moved column usage bitmaps from handler to TABLE Added to TABLE_SHARE all_set and column_bitmap_size Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set. Declared all new table column bitmap functions Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps() Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val(). sql/tztime.cc: Mark all columns as used for timezone tables storage/archive/ha_archive.cc: Update to new handler interface storage/archive/ha_archive.h: Update to new handler interface storage/blackhole/ha_blackhole.cc: Update to new handler interface storage/blackhole/ha_blackhole.h: Update to new handler interface removed not needed flag HA_DUPP_POS storage/csv/ha_tina.cc: Update to new handler interface storage/csv/ha_tina.h: Update to new handler interface storage/example/ha_example.cc: Update to new handler interface storage/example/ha_example.h: Update to new handler interface storage/heap/hp_extra.c: Added heap_reset() (Required by new handler interface) storage/heap/hp_test2.c: Use heap_reset() storage/myisam/ft_boolean_search.c: Fixed compiler warning storage/myisam/mi_extra.c: Added mi_reset() (Required by new handler interface) storage/myisam/mi_search.c: Fixed DBUG_PRINT messages to use 0x%lx instead of %lx storage/myisam/mi_test2.c: Use mi_reset() storage/myisam/myisampack.c: Use mi_reset() storage/myisammrg/myrg_extra.c: Added myrg_reset() (Required by new handler interface) unittest/mysys/base64.t.c: Include my_global.h Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
{
if ((*order->item)->walk(processor, walk_subquery, argument))
return 1;
}
}
}
return (this->*processor)(argument);
}
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
bool Item_subselect::exec()
{
int res;
Simpler arena swapping code Now thd->mem_root is a pointer to thd->main_mem_root and THR_MALLOC is a pointer to thd->mem_root. This gives us the following benefits: - Allow us to easily detect if arena has already been swapped before (this fixes a bug in setup_conds() where arena was swaped twice in some cases) - Faster swaps of arenas (as we don't have to copy the whole MEM_ROOT) - We don't anymore have to call my_pthread_setspecific_ptr(THR_MALLOC,...) to change where memory is alloced. Now it's enough to set thd->mem_root client/mysqltest.c: Remove some not needed defines (Things like this should be done in config-win.h) include/config-win.h: Added popen() and pclose() compatibility macros mysql-test/t/rpl_failed_optimize-master.opt: Portability fix sql/ha_berkeley.cc: New thd->memroot handling sql/item_cmpfunc.cc: Simpler arena swapping code sql/item_func.cc: Simpler arena swapping code sql/item_subselect.cc: Simpler arena swapping code New thd->mem_root handling sql/item_sum.cc: New thd->mem_root handling sql/item_timefunc.cc: Fixed not-initalized usage errors found by valgrind sql/log_event.cc: New thd->mem_root handling sql/mysql_priv.h: New thd->mem_root handling sql/mysqld.cc: New thd->mem_root handling sql/opt_range.cc: New thd->mem_root handling sql/repl_failsafe.cc: New thd->mem_root handling sql/set_var.cc: New thd->mem_root handling sql/sql_acl.cc: New thd->mem_root handling sql/sql_base.cc: Simpler arena swapping code New thd->mem_root handling sql/sql_class.cc: New thd->mem_root handling sql/sql_class.h: Simpler arena swapping code New thd->mem_root handling sql/sql_db.cc: New thd->mem_root handling sql/sql_error.cc: New thd->mem_root handling sql/sql_help.cc: New thd->mem_root handling sql/sql_insert.cc: New thd->mem_root handling sql/sql_parse.cc: New thd->mem_root handling Added some extra checking of return value of new sql/sql_prepare.cc: New thd->mem_root handling sql/sql_select.cc: New thd->mem_root handling sql/sql_select.h: New thd->mem_root handling sql/sql_union.cc: Simpler arena swapping code sql/sql_yacc.yy: New thd->mem_root handling sql/table.cc: New thd->mem_root handling sql/thr_malloc.cc: New thd->mem_root handling tests/client_test.c: Added drop table to some tests Changed some table names to 't1'
2004-11-08 00:13:54 +01:00
/*
Do not execute subselect in case of a fatal error
or if the query has been killed.
*/
if (thd->is_error() || thd->killed)
Fixed bug #24653. The bug report has demonstrated the following two problems. 1. If an ORDER/GROUP BY list includes a constant expression being optimized away and, at the same time, containing single-row subselects that return more that one row, no error is reported. Strictly speaking the standard allows to ignore error in this case. Yet, now a corresponding fatal error is reported in this case. 2. If a query requires sorting by expressions containing single-row subselects that, however, return more than one row, then the execution of the query may cause a server crash. To fix this some code has been added that blocks execution of a subselect item in case of a fatal error in the method Item_subselect::exec. mysql-test/r/subselect.result: Added a test cases for bug #24653. mysql-test/t/subselect.test: Added a test cases for bug #24653. sql/filesort.cc: Fixed bug #24653. Added a check for fatal error after reading the next row from the table in the function find_all_keys. sql/item.cc: Fixed bug #24653. Down-ported calculation of the attribute with_subselect of for Item objects. sql/item.h: Fixed bug #24653. Down-ported calculation of the attribute with_subselect of for Item objects. sql/item_cmpfunc.cc: Fixed bug #24653. Down-ported calculation of the attribute with_subselect of for Item objects. sql/item_cmpfunc.h: Fixed bug #24653. Down-ported calculation of the attribute with_subselect of for Item objects. sql/item_func.cc: Fixed bug #24653. Down-ported calculation of the attribute with_subselect of for Item objects. sql/item_subselect.cc: Fixed bug #24653. Added a check for fatal error in the method Item_subselect::exec to block evaluation of subselects in erroneous situations. Down-ported calculation of the attribute with_subselect of for Item objects. sql/sql_select.cc: Fixed bug #24653. Added a check to verify that any constant expression used in ORDER BY and/or GROUP BY lists which is optimized away does not contain subselects returning more than one row. If it does a fatal error is reported.
2007-01-26 03:44:35 +01:00
return 1;
Fixed following problems: --Bug#52157 various crashes and assertions with multi-table update, stored function --Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb --Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846 --Bug#57352 valgrind warnings when creating view --Recently discovered problem when a nested materialized derived table is used before being populated and it leads to incorrect result We have several modes when we should disable subquery evaluation. The reasons for disabling are different. It could be uselessness of the evaluation as in case of 'CREATE VIEW' or 'PREPARE stmt', or we should disable subquery evaluation if tables are not locked yet as it happens in bug#54475, or too early evaluation of subqueries can lead to wrong result as it happened in Bug#19077. Main problem is that if subquery items are treated as const they are evaluated in ::fix_fields(), ::fix_length_and_dec() of the parental items as a lot of these methods have Item::val_...() calls inside. We have to make subqueries non-const to prevent unnecessary subquery evaluation. At the moment we have different methods for this. Here is a list of these modes: 1. PREPARE stmt; We use UNCACHEABLE_PREPARE flag. It is set during parsing in sql_parse.cc, mysql_new_select() for each SELECT_LEX object and cleared at the end of PREPARE in sql_prepare.cc, init_stmt_after_parse(). If this flag is set subquery becomes non-const and evaluation does not happen. 2. CREATE|ALTER VIEW, SHOW CREATE VIEW, I_S tables which process FRM files We use LEX::view_prepare_mode field. We set it before view preparation and check this flag in ::fix_fields(), ::fix_length_and_dec(). Some bugs are fixed using this approach, some are not(Bug#57352, Bug#57703). The problem here is that we have a lot of ::fix_fields(), ::fix_length_and_dec() where we use Item::val_...() calls for const items. 3. Derived tables with subquery = wrong result(Bug19077) The reason of this bug is too early subquery evaluation. It was fixed by adding Item::with_subselect field The check of this field in appropriate places prevents const item evaluation if the item have subquery. The fix for Bug19077 fixes only the problem with convert_constant_item() function and does not cover other places(::fix_fields(), ::fix_length_and_dec() again) where subqueries could be evaluated. Example: CREATE TABLE t1 (i INT, j BIGINT); INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2); SELECT * FROM (SELECT MIN(i) FROM t1 WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3; DROP TABLE t1; 4. Derived tables with subquery where subquery is evaluated before table locking(Bug#54475, Bug#52157) Suggested solution is following: -Introduce new field LEX::context_analysis_only with the following possible flags: #define CONTEXT_ANALYSIS_ONLY_PREPARE 1 #define CONTEXT_ANALYSIS_ONLY_VIEW 2 #define CONTEXT_ANALYSIS_ONLY_DERIVED 4 -Set/clean these flags when we perform context analysis operation -Item_subselect::const_item() returns result depending on LEX::context_analysis_only. If context_analysis_only is set then we return FALSE that means that subquery is non-const. As all subquery types are wrapped by Item_subselect it allow as to make subquery non-const when it's necessary. mysql-test/r/derived.result: test case mysql-test/r/multi_update.result: test case mysql-test/r/view.result: test case mysql-test/suite/innodb/r/innodb_multi_update.result: test case mysql-test/suite/innodb/t/innodb_multi_update.test: test case mysql-test/suite/innodb_plugin/r/innodb_multi_update.result: test case mysql-test/suite/innodb_plugin/t/innodb_multi_update.test: test case mysql-test/t/derived.test: test case mysql-test/t/multi_update.test: test case mysql-test/t/view.test: test case sql/item.cc: --removed unnecessary code sql/item_cmpfunc.cc: --removed unnecessary checks --THD::is_context_analysis_only() is replaced with LEX::is_ps_or_view_context_analysis() sql/item_func.cc: --refactored context analysis checks sql/item_row.cc: --removed unnecessary checks sql/item_subselect.cc: --removed unnecessary code --added DBUG_ASSERT into Item_subselect::exec() which asserts that subquery execution can not happen if LEX::context_analysis_only is set, i.e. at context analysis stage. --Item_subselect::const_item() Return FALSE if LEX::context_analysis_only is set. It prevents subquery evaluation in ::fix_fields & ::fix_length_and_dec at context analysis stage. sql/item_subselect.h: --removed unnecessary code sql/mysql_priv.h: --Added new set of flags. sql/sql_class.h: --removed unnecessary code sql/sql_derived.cc: --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_lex.cc: --init LEX::context_analysis_only field sql/sql_lex.h: --New LEX::context_analysis_only field sql/sql_parse.cc: --removed unnecessary code sql/sql_prepare.cc: --removed unnecessary code --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_select.cc: --refactored context analysis checks sql/sql_show.cc: --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_view.cc: --added LEX::context_analysis_only analysis intialization/cleanup
2010-12-14 10:33:03 +01:00
DBUG_ASSERT(!thd->lex->context_analysis_only);
/*
Simulate a failure in sub-query execution. Used to test e.g.
out of memory or query being killed conditions.
*/
DBUG_EXECUTE_IF("subselect_exec_fail", return 1;);
Simpler arena swapping code Now thd->mem_root is a pointer to thd->main_mem_root and THR_MALLOC is a pointer to thd->mem_root. This gives us the following benefits: - Allow us to easily detect if arena has already been swapped before (this fixes a bug in setup_conds() where arena was swaped twice in some cases) - Faster swaps of arenas (as we don't have to copy the whole MEM_ROOT) - We don't anymore have to call my_pthread_setspecific_ptr(THR_MALLOC,...) to change where memory is alloced. Now it's enough to set thd->mem_root client/mysqltest.c: Remove some not needed defines (Things like this should be done in config-win.h) include/config-win.h: Added popen() and pclose() compatibility macros mysql-test/t/rpl_failed_optimize-master.opt: Portability fix sql/ha_berkeley.cc: New thd->memroot handling sql/item_cmpfunc.cc: Simpler arena swapping code sql/item_func.cc: Simpler arena swapping code sql/item_subselect.cc: Simpler arena swapping code New thd->mem_root handling sql/item_sum.cc: New thd->mem_root handling sql/item_timefunc.cc: Fixed not-initalized usage errors found by valgrind sql/log_event.cc: New thd->mem_root handling sql/mysql_priv.h: New thd->mem_root handling sql/mysqld.cc: New thd->mem_root handling sql/opt_range.cc: New thd->mem_root handling sql/repl_failsafe.cc: New thd->mem_root handling sql/set_var.cc: New thd->mem_root handling sql/sql_acl.cc: New thd->mem_root handling sql/sql_base.cc: Simpler arena swapping code New thd->mem_root handling sql/sql_class.cc: New thd->mem_root handling sql/sql_class.h: Simpler arena swapping code New thd->mem_root handling sql/sql_db.cc: New thd->mem_root handling sql/sql_error.cc: New thd->mem_root handling sql/sql_help.cc: New thd->mem_root handling sql/sql_insert.cc: New thd->mem_root handling sql/sql_parse.cc: New thd->mem_root handling Added some extra checking of return value of new sql/sql_prepare.cc: New thd->mem_root handling sql/sql_select.cc: New thd->mem_root handling sql/sql_select.h: New thd->mem_root handling sql/sql_union.cc: Simpler arena swapping code sql/sql_yacc.yy: New thd->mem_root handling sql/table.cc: New thd->mem_root handling sql/thr_malloc.cc: New thd->mem_root handling tests/client_test.c: Added drop table to some tests Changed some table names to 't1'
2004-11-08 00:13:54 +01:00
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
res= engine->exec();
#ifndef DBUG_OFF
++exec_counter;
#endif
if (engine_changed)
{
engine_changed= 0;
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
return exec();
}
return (res);
}
Fixed LP BUG#800696. The problem was that optimizer removes some outer references (it they are constant for example) and the list of outer items built during prepare phase is not actual during execution phase when we need it as the cache parameters. First solution was use pointer on pointer on outer reference Item and initialize temporary table on demand. This solved most problem except case when optimiser also reduce Item which contains outer references ('OR' in this bug test suite). The solution is to build the list of outer reference items on execution phase (after optimization) on demand (just before temporary table creation) by walking Item tree and finding outer references among Item_ident (Item_field/Item_ref) and Item_sum items. Removed depends_on list (because it is not neede any mnore for the cache, in the place where it was used it replaced with upper_refs). Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references (or other expression parameters in future). mysql-test/r/subselect_cache.result: A new test added. mysql-test/r/subselect_scache.result: Changes in creating the cache and its paremeters order or adding arguments of aggregate function (which is a parameter also, but this has no influence on the result). mysql-test/t/subselect_cache.test: Added a new test. sql/item.cc: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. Item_cache_wrapper collect parameters befor initialization of its cache. sql/item.h: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/item_cmpfunc.cc: depends_on removed. Added processor (collect_outer_ref_processor) to collect outer references. sql/item_cmpfunc.h: Added processor (collect_outer_ref_processor) to collect outer references. sql/item_subselect.cc: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_subselect.h: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_sum.cc: Added processor (collect_outer_ref_processor) method to collect outer references. sql/item_sum.h: Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/opt_range.cc: depends_on removed. sql/sql_base.cc: depends_on removed. sql/sql_class.h: New iterator added. sql/sql_expression_cache.cc: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_expression_cache.h: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_lex.cc: depends_on removed. sql/sql_lex.h: depends_on removed. sql/sql_list.h: Added add_unique method to add only unique elements to the list. sql/sql_select.cc: Support of new Item list added. sql/sql_select.h: Support of new Item list added.
2011-07-19 22:19:10 +02:00
void Item_subselect::get_cache_parameters(List<Item> &parameters)
{
Collect_deps_prm prm= {&parameters,
unit->first_select()->nest_level_base,
unit->first_select()->nest_level};
Fixed LP BUG#800696. The problem was that optimizer removes some outer references (it they are constant for example) and the list of outer items built during prepare phase is not actual during execution phase when we need it as the cache parameters. First solution was use pointer on pointer on outer reference Item and initialize temporary table on demand. This solved most problem except case when optimiser also reduce Item which contains outer references ('OR' in this bug test suite). The solution is to build the list of outer reference items on execution phase (after optimization) on demand (just before temporary table creation) by walking Item tree and finding outer references among Item_ident (Item_field/Item_ref) and Item_sum items. Removed depends_on list (because it is not neede any mnore for the cache, in the place where it was used it replaced with upper_refs). Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references (or other expression parameters in future). mysql-test/r/subselect_cache.result: A new test added. mysql-test/r/subselect_scache.result: Changes in creating the cache and its paremeters order or adding arguments of aggregate function (which is a parameter also, but this has no influence on the result). mysql-test/t/subselect_cache.test: Added a new test. sql/item.cc: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. Item_cache_wrapper collect parameters befor initialization of its cache. sql/item.h: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/item_cmpfunc.cc: depends_on removed. Added processor (collect_outer_ref_processor) to collect outer references. sql/item_cmpfunc.h: Added processor (collect_outer_ref_processor) to collect outer references. sql/item_subselect.cc: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_subselect.h: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_sum.cc: Added processor (collect_outer_ref_processor) method to collect outer references. sql/item_sum.h: Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/opt_range.cc: depends_on removed. sql/sql_base.cc: depends_on removed. sql/sql_class.h: New iterator added. sql/sql_expression_cache.cc: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_expression_cache.h: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_lex.cc: depends_on removed. sql/sql_lex.h: depends_on removed. sql/sql_list.h: Added add_unique method to add only unique elements to the list. sql/sql_select.cc: Support of new Item list added. sql/sql_select.h: Support of new Item list added.
2011-07-19 22:19:10 +02:00
walk(&Item::collect_outer_ref_processor, TRUE, (uchar*)&prm);
}
2011-05-25 17:31:13 +02:00
int Item_in_subselect::optimize(double *out_rows, double *cost)
{
int res;
DBUG_ENTER("Item_in_subselect::optimize");
SELECT_LEX *save_select= thd->lex->current_select;
JOIN *join= unit->first_select()->join;
thd->lex->current_select= join->select_lex;
if ((res= join->optimize()))
DBUG_RETURN(res);
2011-05-25 17:31:13 +02:00
/* Calculate #rows and cost of join execution */
join->get_partial_cost_and_fanout(join->table_count - join->const_tables,
table_map(-1),
cost, out_rows);
/*
Adjust join output cardinality. There can be these cases:
- Have no GROUP BY and no aggregate funcs: we won't get into this
function because such join will be processed as a merged semi-join
(TODO: does it really mean we don't need to handle such cases here at
all? put ASSERT)
- Have no GROUP BY but have aggregate funcs: output is 1 record.
- Have GROUP BY and have (or not) aggregate funcs: need to adjust output
cardinality.
*/
thd->lex->current_select= save_select;
if (!join->group_list && !join->group_optimized_away &&
join->tmp_table_param.sum_func_count)
{
DBUG_PRINT("info",("Materialized join will have only 1 row (it has "
"aggregates but no GROUP BY"));
*out_rows= 1;
}
/* Now with grouping */
if (join->group_list)
{
DBUG_PRINT("info",("Materialized join has grouping, trying to estimate it"));
double output_rows= get_post_group_estimate(join, *out_rows);
DBUG_PRINT("info",("Got value of %g", output_rows));
*out_rows= output_rows;
}
DBUG_RETURN(res);
}
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
/**
Check if an expression cache is needed for this subquery
@param thd Thread handle
@details
The function checks whether a cache is needed for a subquery and whether
the result of the subquery can be put in cache.
@retval TRUE cache is needed
@retval FALSE otherwise
*/
bool Item_subselect::expr_cache_is_needed(THD *thd)
{
Fixed LP BUG#800696. The problem was that optimizer removes some outer references (it they are constant for example) and the list of outer items built during prepare phase is not actual during execution phase when we need it as the cache parameters. First solution was use pointer on pointer on outer reference Item and initialize temporary table on demand. This solved most problem except case when optimiser also reduce Item which contains outer references ('OR' in this bug test suite). The solution is to build the list of outer reference items on execution phase (after optimization) on demand (just before temporary table creation) by walking Item tree and finding outer references among Item_ident (Item_field/Item_ref) and Item_sum items. Removed depends_on list (because it is not neede any mnore for the cache, in the place where it was used it replaced with upper_refs). Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references (or other expression parameters in future). mysql-test/r/subselect_cache.result: A new test added. mysql-test/r/subselect_scache.result: Changes in creating the cache and its paremeters order or adding arguments of aggregate function (which is a parameter also, but this has no influence on the result). mysql-test/t/subselect_cache.test: Added a new test. sql/item.cc: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. Item_cache_wrapper collect parameters befor initialization of its cache. sql/item.h: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/item_cmpfunc.cc: depends_on removed. Added processor (collect_outer_ref_processor) to collect outer references. sql/item_cmpfunc.h: Added processor (collect_outer_ref_processor) to collect outer references. sql/item_subselect.cc: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_subselect.h: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_sum.cc: Added processor (collect_outer_ref_processor) method to collect outer references. sql/item_sum.h: Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/opt_range.cc: depends_on removed. sql/sql_base.cc: depends_on removed. sql/sql_class.h: New iterator added. sql/sql_expression_cache.cc: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_expression_cache.h: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_lex.cc: depends_on removed. sql/sql_lex.h: depends_on removed. sql/sql_list.h: Added add_unique method to add only unique elements to the list. sql/sql_select.cc: Support of new Item list added. sql/sql_select.h: Support of new Item list added.
2011-07-19 22:19:10 +02:00
return ((engine->uncacheable() & UNCACHEABLE_DEPENDENT) &&
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
engine->cols() == 1 &&
optimizer_flag(thd, OPTIMIZER_SWITCH_SUBQUERY_CACHE) &&
!(engine->uncacheable() & (UNCACHEABLE_RAND |
UNCACHEABLE_SIDEEFFECT)));
}
/**
Check if an expression cache is needed for this subquery
@param thd Thread handle
@details
The function checks whether a cache is needed for a subquery and whether
the result of the subquery can be put in cache.
@note
This method allows many columns in the subquery because it is supported by
Item_in optimizer and result of the IN subquery will be scalar in this
case.
@retval TRUE cache is needed
@retval FALSE otherwise
*/
bool Item_in_subselect::expr_cache_is_needed(THD *thd)
{
Fixed LP BUG#800696. The problem was that optimizer removes some outer references (it they are constant for example) and the list of outer items built during prepare phase is not actual during execution phase when we need it as the cache parameters. First solution was use pointer on pointer on outer reference Item and initialize temporary table on demand. This solved most problem except case when optimiser also reduce Item which contains outer references ('OR' in this bug test suite). The solution is to build the list of outer reference items on execution phase (after optimization) on demand (just before temporary table creation) by walking Item tree and finding outer references among Item_ident (Item_field/Item_ref) and Item_sum items. Removed depends_on list (because it is not neede any mnore for the cache, in the place where it was used it replaced with upper_refs). Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references (or other expression parameters in future). mysql-test/r/subselect_cache.result: A new test added. mysql-test/r/subselect_scache.result: Changes in creating the cache and its paremeters order or adding arguments of aggregate function (which is a parameter also, but this has no influence on the result). mysql-test/t/subselect_cache.test: Added a new test. sql/item.cc: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. Item_cache_wrapper collect parameters befor initialization of its cache. sql/item.h: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/item_cmpfunc.cc: depends_on removed. Added processor (collect_outer_ref_processor) to collect outer references. sql/item_cmpfunc.h: Added processor (collect_outer_ref_processor) to collect outer references. sql/item_subselect.cc: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_subselect.h: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_sum.cc: Added processor (collect_outer_ref_processor) method to collect outer references. sql/item_sum.h: Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/opt_range.cc: depends_on removed. sql/sql_base.cc: depends_on removed. sql/sql_class.h: New iterator added. sql/sql_expression_cache.cc: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_expression_cache.h: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_lex.cc: depends_on removed. sql/sql_lex.h: depends_on removed. sql/sql_list.h: Added add_unique method to add only unique elements to the list. sql/sql_select.cc: Support of new Item list added. sql/sql_select.h: Support of new Item list added.
2011-07-19 22:19:10 +02:00
return (optimizer_flag(thd, OPTIMIZER_SWITCH_SUBQUERY_CACHE) &&
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
!(engine->uncacheable() & (UNCACHEABLE_RAND |
UNCACHEABLE_SIDEEFFECT)));
}
/*
Compute the IN predicate if the left operand's cache changed.
*/
bool Item_in_subselect::exec()
{
DBUG_ENTER("Item_in_subselect::exec");
/*
Initialize the cache of the left predicate operand. This has to be done as
late as now, because Cached_item directly contains a resolved field (not
an item, and in some cases (when temp tables are created), these fields
end up pointing to the wrong field. One solution is to change Cached_item
to not resolve its field upon creation, but to resolve it dynamically
from a given Item_ref object.
TODO: the cache should be applied conditionally based on:
- rules - e.g. only if the left operand is known to be ordered, and/or
- on a cost-based basis, that takes into account the cost of a cache
lookup, the cache hit rate, and the savings per cache hit.
*/
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
if (!left_expr_cache && (test_strategy(SUBS_MATERIALIZATION)))
init_left_expr_cache();
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
If the new left operand is already in the cache, reuse the old result.
Use the cached result only if this is not the first execution of IN
because the cache is not valid for the first execution.
*/
if (!first_execution && left_expr_cache &&
test_if_item_cache_changed(*left_expr_cache) < 0)
DBUG_RETURN(FALSE);
/*
The exec() method below updates item::value, and item::null_value, thus if
we don't call it, the next call to item::val_int() will return whatever
result was computed by its previous call.
*/
DBUG_RETURN(Item_subselect::exec());
}
Item::Type Item_subselect::type() const
{
return SUBSELECT_ITEM;
}
void Item_subselect::fix_length_and_dec()
{
engine->fix_length_and_dec(0);
simple subselects ported to new select_lex structures include/mysqld_error.h: simple subselects libmysqld/Makefile.am: simple subselects sql/Makefile.am: simple subselects sql/item.h: simple subselects sql/item_strfunc.h: simple subselects sql/share/czech/errmsg.txt: simple subselects sql/share/danish/errmsg.txt: simple subselects sql/share/dutch/errmsg.txt: simple subselects sql/share/english/errmsg.txt: simple subselects sql/share/estonian/errmsg.txt: simple subselects sql/share/french/errmsg.txt: simple subselects sql/share/german/errmsg.txt: simple subselects sql/share/greek/errmsg.txt: simple subselects sql/share/hungarian/errmsg.txt: simple subselects sql/share/italian/errmsg.txt: simple subselects sql/share/japanese/errmsg.txt: simple subselects sql/share/korean/errmsg.txt: simple subselects sql/share/norwegian-ny/errmsg.txt: simple subselects sql/share/norwegian/errmsg.txt: simple subselects sql/share/polish/errmsg.txt: simple subselects sql/share/portuguese/errmsg.txt: simple subselects sql/share/romanian/errmsg.txt: simple subselects sql/share/russian/errmsg.txt: simple subselects sql/share/slovak/errmsg.txt: simple subselects sql/share/spanish/errmsg.txt: simple subselects sql/share/swedish/errmsg.txt: simple subselects sql/share/ukrainian/errmsg.txt: simple subselects sql/sql_class.cc: simple subselects sql/sql_class.h: simple subselects sql/sql_lex.cc: simple subselects sql/sql_select.cc: simple subselects sql/sql_select.h: simple subselects sql/sql_union.cc: simple subselects sql/sql_yacc.yy: simple subselects
2002-05-12 22:46:42 +02:00
}
table_map Item_subselect::used_tables() const
{
return (table_map) ((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN)?
used_tables_cache : 0L);
}
bool Item_subselect::const_item() const
{
Fixed following problems: --Bug#52157 various crashes and assertions with multi-table update, stored function --Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb --Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846 --Bug#57352 valgrind warnings when creating view --Recently discovered problem when a nested materialized derived table is used before being populated and it leads to incorrect result We have several modes when we should disable subquery evaluation. The reasons for disabling are different. It could be uselessness of the evaluation as in case of 'CREATE VIEW' or 'PREPARE stmt', or we should disable subquery evaluation if tables are not locked yet as it happens in bug#54475, or too early evaluation of subqueries can lead to wrong result as it happened in Bug#19077. Main problem is that if subquery items are treated as const they are evaluated in ::fix_fields(), ::fix_length_and_dec() of the parental items as a lot of these methods have Item::val_...() calls inside. We have to make subqueries non-const to prevent unnecessary subquery evaluation. At the moment we have different methods for this. Here is a list of these modes: 1. PREPARE stmt; We use UNCACHEABLE_PREPARE flag. It is set during parsing in sql_parse.cc, mysql_new_select() for each SELECT_LEX object and cleared at the end of PREPARE in sql_prepare.cc, init_stmt_after_parse(). If this flag is set subquery becomes non-const and evaluation does not happen. 2. CREATE|ALTER VIEW, SHOW CREATE VIEW, I_S tables which process FRM files We use LEX::view_prepare_mode field. We set it before view preparation and check this flag in ::fix_fields(), ::fix_length_and_dec(). Some bugs are fixed using this approach, some are not(Bug#57352, Bug#57703). The problem here is that we have a lot of ::fix_fields(), ::fix_length_and_dec() where we use Item::val_...() calls for const items. 3. Derived tables with subquery = wrong result(Bug19077) The reason of this bug is too early subquery evaluation. It was fixed by adding Item::with_subselect field The check of this field in appropriate places prevents const item evaluation if the item have subquery. The fix for Bug19077 fixes only the problem with convert_constant_item() function and does not cover other places(::fix_fields(), ::fix_length_and_dec() again) where subqueries could be evaluated. Example: CREATE TABLE t1 (i INT, j BIGINT); INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2); SELECT * FROM (SELECT MIN(i) FROM t1 WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3; DROP TABLE t1; 4. Derived tables with subquery where subquery is evaluated before table locking(Bug#54475, Bug#52157) Suggested solution is following: -Introduce new field LEX::context_analysis_only with the following possible flags: #define CONTEXT_ANALYSIS_ONLY_PREPARE 1 #define CONTEXT_ANALYSIS_ONLY_VIEW 2 #define CONTEXT_ANALYSIS_ONLY_DERIVED 4 -Set/clean these flags when we perform context analysis operation -Item_subselect::const_item() returns result depending on LEX::context_analysis_only. If context_analysis_only is set then we return FALSE that means that subquery is non-const. As all subquery types are wrapped by Item_subselect it allow as to make subquery non-const when it's necessary. mysql-test/r/derived.result: test case mysql-test/r/multi_update.result: test case mysql-test/r/view.result: test case mysql-test/suite/innodb/r/innodb_multi_update.result: test case mysql-test/suite/innodb/t/innodb_multi_update.test: test case mysql-test/suite/innodb_plugin/r/innodb_multi_update.result: test case mysql-test/suite/innodb_plugin/t/innodb_multi_update.test: test case mysql-test/t/derived.test: test case mysql-test/t/multi_update.test: test case mysql-test/t/view.test: test case sql/item.cc: --removed unnecessary code sql/item_cmpfunc.cc: --removed unnecessary checks --THD::is_context_analysis_only() is replaced with LEX::is_ps_or_view_context_analysis() sql/item_func.cc: --refactored context analysis checks sql/item_row.cc: --removed unnecessary checks sql/item_subselect.cc: --removed unnecessary code --added DBUG_ASSERT into Item_subselect::exec() which asserts that subquery execution can not happen if LEX::context_analysis_only is set, i.e. at context analysis stage. --Item_subselect::const_item() Return FALSE if LEX::context_analysis_only is set. It prevents subquery evaluation in ::fix_fields & ::fix_length_and_dec at context analysis stage. sql/item_subselect.h: --removed unnecessary code sql/mysql_priv.h: --Added new set of flags. sql/sql_class.h: --removed unnecessary code sql/sql_derived.cc: --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_lex.cc: --init LEX::context_analysis_only field sql/sql_lex.h: --New LEX::context_analysis_only field sql/sql_parse.cc: --removed unnecessary code sql/sql_prepare.cc: --removed unnecessary code --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_select.cc: --refactored context analysis checks sql/sql_show.cc: --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_view.cc: --added LEX::context_analysis_only analysis intialization/cleanup
2010-12-14 10:33:03 +01:00
return thd->lex->context_analysis_only ? FALSE : const_item_cache;
}
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
Item *Item_subselect::get_tmp_table_item(THD *thd_arg)
{
if (!with_sum_func && !const_item())
return new Item_field(result_field);
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
return copy_or_same(thd_arg);
}
void Item_subselect::update_used_tables()
{
if (!forced_const)
{
recalc_used_tables(parent_select, FALSE);
if (!engine->uncacheable())
{
// did all used tables become static?
if (!(used_tables_cache & ~engine->upper_select_const_tables()))
const_item_cache= 1;
}
}
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
void Item_subselect::print(String *str, enum_query_type query_type)
{
if (engine)
{
str->append('(');
engine->print(str, query_type);
str->append(')');
}
else
str->append("(...)");
}
2003-10-07 07:51:09 +02:00
Item_singlerow_subselect::Item_singlerow_subselect(st_select_lex *select_lex)
:Item_subselect(), value(0)
{
DBUG_ENTER("Item_singlerow_subselect::Item_singlerow_subselect");
init(select_lex, new select_singlerow_subselect(this));
maybe_null= 1;
max_columns= UINT_MAX;
DBUG_VOID_RETURN;
}
st_select_lex *
Item_singlerow_subselect::invalidate_and_restore_select_lex()
{
DBUG_ENTER("Item_singlerow_subselect::invalidate_and_restore_select_lex");
st_select_lex *result= get_select_lex();
DBUG_ASSERT(result);
/*
This code restore the parse tree in it's state before the execution of
Item_singlerow_subselect::Item_singlerow_subselect(),
and in particular decouples this object from the SELECT_LEX,
so that the SELECT_LEX can be used with a different flavor
or Item_subselect instead, as part of query rewriting.
*/
unit->item= NULL;
DBUG_RETURN(result);
}
Item_maxmin_subselect::Item_maxmin_subselect(THD *thd_param,
Item_subselect *parent,
st_select_lex *select_lex,
bool max_arg)
:Item_singlerow_subselect(), was_values(TRUE)
{
DBUG_ENTER("Item_maxmin_subselect::Item_maxmin_subselect");
max= max_arg;
init(select_lex,
new select_max_min_finder_subselect(this, max_arg,
parent->substype() ==
Item_subselect::ALL_SUBS));
max_columns= 1;
maybe_null= 1;
max_columns= 1;
/*
Following information was collected during performing fix_fields()
of Items belonged to subquery, which will be not repeated
*/
used_tables_cache= parent->get_used_tables_cache();
const_item_cache= parent->const_item();
/*
this subquery always creates during preparation, so we can assign
thd here
*/
thd= thd_param;
DBUG_VOID_RETURN;
}
void Item_maxmin_subselect::cleanup()
{
DBUG_ENTER("Item_maxmin_subselect::cleanup");
Item_singlerow_subselect::cleanup();
/*
By default it is TRUE to avoid TRUE reporting by
Item_func_not_all/Item_func_nop_all if this item was never called.
Engine exec() set it to FALSE by reset_value_registration() call.
select_max_min_finder_subselect::send_data() set it back to TRUE if some
value will be found.
*/
was_values= TRUE;
DBUG_VOID_RETURN;
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
void Item_maxmin_subselect::print(String *str, enum_query_type query_type)
{
added code covarage for functions convert(), nullif(), crc32(), is_used_lock(), char_lengtrh(), bit_xor() added string length for more speed made code covarage for print() method of Item fixed printability of some items (SCRUM) (WL#1274) mysql-test/r/auto_increment.result: print() code coverage mysql-test/r/bench_count_distinct.result: print() code coverage mysql-test/r/case.result: print() code coverage mysql-test/r/cast.result: print() code coverage mysql-test/r/ctype_collate.result: print() code coverage mysql-test/r/ctype_many.result: convert with 3 arguments code covarage print() code coverage mysql-test/r/ctype_utf8.result: char_length code coverage mysql-test/r/date_formats.result: print() code coverage mysql-test/r/fulltext.result: print() code coverage mysql-test/r/func_compress.result: print() code coverage mysql-test/r/func_gconcat.result: print() code coverage mysql-test/r/func_group.result: bit_xor() code coverage print() code coverage mysql-test/r/func_if.result: nullif() code coverage print() code coverage mysql-test/r/func_in.result: print() code coverage mysql-test/r/func_math.result: print() code coverage mysql-test/r/func_op.result: print() code coverage mysql-test/r/func_regexp.result: print() code coverage mysql-test/r/func_set.result: print() code coverage mysql-test/r/func_str.result: crc32() code coverage print() code coverage mysql-test/r/func_system.result: print() code coverage mysql-test/r/func_test.result: print() code coverage mysql-test/r/func_time.result: print() code coverage mysql-test/r/group_by.result: print() code coverage mysql-test/r/having.result: print() code coverage mysql-test/r/insert_update.result: print() code coverage mysql-test/r/null.result: print() code coverage mysql-test/r/olap.result: print() code coverage mysql-test/r/query_cache.result: print() code coverage mysql-test/r/row.result: print() code coverage mysql-test/r/rpl000001.result: print() code coverage mysql-test/r/rpl_get_lock.result: print() code coverage mysql-test/r/rpl_master_pos_wait.result: print() code coverage mysql-test/r/select.result: print() code coverage mysql-test/r/subselect.result: print() code coverage mysql-test/r/type_blob.result: print() code coverage mysql-test/r/varbinary.result: print() code coverage mysql-test/r/variables.result: print() code coverage mysql-test/t/auto_increment.test: print() code coverage mysql-test/t/bench_count_distinct.test: print() code coverage mysql-test/t/case.test: print() code coverage mysql-test/t/cast.test: print() code coverage mysql-test/t/ctype_collate.test: print() code coverage mysql-test/t/ctype_many.test: convert with 3 arguments code covarage print() code coverage mysql-test/t/ctype_utf8.test: char_length code coverage mysql-test/t/date_formats.test: print() code coverage mysql-test/t/fulltext.test: print() code coverage mysql-test/t/func_compress.test: print() code coverage mysql-test/t/func_gconcat.test: print() code coverage mysql-test/t/func_group.test: bit_xor() code coverage print() code coverage mysql-test/t/func_if.test: nullif() code coverage print() code coverage mysql-test/t/func_in.test: print() code coverage mysql-test/t/func_math.test: print() code coverage mysql-test/t/func_op.test: print() code coverage mysql-test/t/func_regexp.test: print() code coverage mysql-test/t/func_set.test: print() code coverage mysql-test/t/func_str.test: crc32() code covarage print() code coverage mysql-test/t/func_system.test: print() code coverage mysql-test/t/func_test.test: print() code coverage mysql-test/t/func_time.test: print() code coverage mysql-test/t/group_by.test: print() code coverage mysql-test/t/having.test: print() code coverage mysql-test/t/insert_update.test: print() code coverage mysql-test/t/null.test: print() code coverage mysql-test/t/olap.test: print() code coverage mysql-test/t/query_cache.test: print() code coverage mysql-test/t/row.test: print() code coverage mysql-test/t/rpl000001.test: print() code coverage mysql-test/t/rpl_get_lock.test: print() code coverage mysql-test/t/rpl_master_pos_wait.test: print() code coverage mysql-test/t/select.test: print() code coverage mysql-test/t/type_blob.test: print() code coverage mysql-test/t/varbinary.test: print() code coverage mysql-test/t/variables.test: print() code coverage sql/item.cc: added string length for more speed layout fix fixed string printability sql/item.h: added string length for more speed sql/item_cmpfunc.cc: added string length for more speed sql/item_cmpfunc.h: fixed printability sql/item_create.cc: fixed printability sql/item_func.cc: fixed printability added string length for more speed sql/item_func.h: fixed printability sql/item_strfunc.cc: fixed printability added string length for more speed sql/item_strfunc.h: fixed printability sql/item_subselect.cc: added string length for more speed sql/item_sum.cc: added string length for more speed sql/item_timefunc.cc: added string length for more speed sql/item_timefunc.h: fixed printability sql/item_uniq.h: added string length for more speed sql/key.cc: added string length for more speed sql/sql_lex.cc: added string length for more speed sql/sql_parse.cc: after merge fix sql/sql_repl.cc: string changed with character for more speed sql/sql_select.cc: added string length for more speed sql/sql_show.cc: added string length for more speed
2003-10-30 11:57:26 +01:00
str->append(max?"<max>":"<min>", 5);
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
Item_singlerow_subselect::print(str, query_type);
}
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
void Item_maxmin_subselect::no_rows_in_result()
{
Fix bug lp:1008686 Analysis: The fix for bug lp:985667 implements the method Item_subselect::no_rows_in_result() for all main kinds of subqueries. The purpose of this method is to be called from return_zero_rows() and set Items to some default value in the case when a query returns no rows. Aggregates and subqueries require special treatment in this case. Every implementation of Item_subselect::no_rows_in_result() called Item_subselect::make_const() to set the subquery predicate to its default value irrespective of where the predicate was located in the query. Once the predicate was set to a constant it was never executed. At the same time, the JOIN object of the fake select for UNIONs (the one used for the final result of the UNION), was set after all subqueries in the union were executed. Since we set the subquery as constant, it was never executed, and the corresponding JOIN was never created. In order to decide whether the result of NOT IN is NULL or FALSE, Item_in_optimizer needs to check if the subquery result was empty or not. This is where we got the crash, because subselect_union_engine::no_rows() checks for unit->fake_select_lex->join->send_records, and the join object was NULL. Solution: If a subquery is in the HAVING clause it must be evaluated in order to know its result, so that we can properly filter the result records. Once subqueries in the HAVING clause are executed even in the case of no result rows, this specific crash will be solved, because the UNION will be executed, and its JOIN will be constructed. Therefore the fix for this crash is to narrow the fix for lp:985667, and to apply Item_subselect::no_rows_in_result() only when the subquery predicate is in the SELECT clause.
2012-06-15 10:33:24 +02:00
/*
Subquery predicates outside of the SELECT list must be evaluated in order
to possibly filter the special result row generated for implicit grouping
if the subquery is in the HAVING clause.
If the predicate is constant, we need its actual value in the only result
row for queries with implicit grouping.
*/
if (parsing_place != SELECT_LIST || const_item())
return;
value= Item_cache::get_cache(new Item_null());
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
null_value= 0;
was_values= 0;
make_const();
}
void Item_singlerow_subselect::no_rows_in_result()
{
Fix bug lp:1008686 Analysis: The fix for bug lp:985667 implements the method Item_subselect::no_rows_in_result() for all main kinds of subqueries. The purpose of this method is to be called from return_zero_rows() and set Items to some default value in the case when a query returns no rows. Aggregates and subqueries require special treatment in this case. Every implementation of Item_subselect::no_rows_in_result() called Item_subselect::make_const() to set the subquery predicate to its default value irrespective of where the predicate was located in the query. Once the predicate was set to a constant it was never executed. At the same time, the JOIN object of the fake select for UNIONs (the one used for the final result of the UNION), was set after all subqueries in the union were executed. Since we set the subquery as constant, it was never executed, and the corresponding JOIN was never created. In order to decide whether the result of NOT IN is NULL or FALSE, Item_in_optimizer needs to check if the subquery result was empty or not. This is where we got the crash, because subselect_union_engine::no_rows() checks for unit->fake_select_lex->join->send_records, and the join object was NULL. Solution: If a subquery is in the HAVING clause it must be evaluated in order to know its result, so that we can properly filter the result records. Once subqueries in the HAVING clause are executed even in the case of no result rows, this specific crash will be solved, because the UNION will be executed, and its JOIN will be constructed. Therefore the fix for this crash is to narrow the fix for lp:985667, and to apply Item_subselect::no_rows_in_result() only when the subquery predicate is in the SELECT clause.
2012-06-15 10:33:24 +02:00
/*
Subquery predicates outside of the SELECT list must be evaluated in order
to possibly filter the special result row generated for implicit grouping
if the subquery is in the HAVING clause.
If the predicate is constant, we need its actual value in the only result
row for queries with implicit grouping.
*/
if (parsing_place != SELECT_LIST || const_item())
return;
value= Item_cache::get_cache(new Item_null());
reset();
make_const();
}
void Item_singlerow_subselect::reset()
{
Item_subselect::reset();
if (value)
{
for(uint i= 0; i < engine->cols(); i++)
row[i]->set_null();
}
}
2007-10-11 19:29:09 +02:00
/**
@todo
- We cant change name of Item_field or Item_ref, because it will
prevent it's correct resolving, but we should save name of
removed item => we do not make optimization if top item of
list is field or reference.
- switch off this optimization for prepare statement,
because we do not rollback this changes.
Make rollback for it, or special name resolving mode in 5.0.
@param join Join object of the subquery (i.e. 'child' join).
@retval false The subquery was transformed
2007-10-11 19:29:09 +02:00
*/
bool
Item_singlerow_subselect::select_transformer(JOIN *join)
{
DBUG_ENTER("Item_singlerow_subselect::select_transformer");
if (changed)
DBUG_RETURN(false);
SELECT_LEX *select_lex= join->select_lex;
Query_arena *arena= thd->stmt_arena;
merge with 4.1 BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/triggers/post-commit: Auto merged Docs/Support/texi2html: Auto merged Makefile.am: Auto merged client/Makefile.am: Auto merged client/mysql.cc: Auto merged client/mysqldump.c: Auto merged include/my_base.h: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/my_time.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/buf/buf0buf.c: Auto merged innobase/include/row0mysql.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/examples/Makefile.am: Auto merged myisam/mi_check.c: Auto merged mysql-test/include/ps_modify.inc: Auto merged mysql-test/install_test_db.sh: Auto merged mysql-test/r/alter_table.result: Auto merged mysql-test/r/auto_increment.result: Auto merged mysql-test/r/bdb.result: Auto merged mysql-test/r/ctype_latin1_de.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_if.result: Auto merged mysql-test/t/derived.test: Auto merged mysql-test/t/insert.test: merge with 4.1 Fixed test case to not use 'if exists' when it shouldn't mysql-test/t/range.test: merge with 4.1 Added missing drop table sql/ha_ndbcluster.cc: merge with 4.1 Simple optimization: use max() instead of ? : sql/item_func.cc: merge with 4.1 (Added back old variable names for easier merges) sql/opt_range.cc: merge with 4.1 Removed argument 'parent_alloc' from QUICK_RANGE_SELECT as this was not used Added assert if using QUICK_GROUP_MIN_MAX_SELECT with parent_alloc as the init() function can't handle this Changed back get_quick_select_for_ref() to use it's own alloc root becasue this function may be called several times for one query sql/sql_handler.cc: merge with 4.1 change variable 'err' to 'error' as same function had a label named 'err' sql/sql_update.cc: Use multi-update code from 5.0 instead of 4.1 We will fix the locking code shortly in 5.0 to be faster than in 4.1
2004-10-29 18:26:52 +02:00
if (!select_lex->master_unit()->is_union() &&
!select_lex->table_list.elements &&
select_lex->item_list.elements == 1 &&
!select_lex->item_list.head()->with_sum_func &&
/*
We cant change name of Item_field or Item_ref, because it will
prevent it's correct resolving, but we should save name of
removed item => we do not make optimization if top item of
list is field or reference.
TODO: solve above problem
*/
!(select_lex->item_list.head()->type() == FIELD_ITEM ||
select_lex->item_list.head()->type() == REF_ITEM) &&
!join->conds && !join->having &&
/*
switch off this optimization for prepare statement,
because we do not rollback this changes
TODO: make rollback for it, or special name resolving mode in 5.0.
*/
!arena->is_stmt_prepare_or_first_sp_execute()
)
{
have_to_be_excluded= 1;
if (thd->lex->describe)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number);
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_SELECT_REDUCED, warn_buff);
}
substitution= select_lex->item_list.head();
/*
as far as we moved content to upper level, field which depend of
'upper' select is not really dependent => we remove this dependence
*/
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes Changes that requires code changes in other code of other storage engines. (Note that all changes are very straightforward and one should find all issues by compiling a --debug build and fixing all compiler errors and all asserts in field.cc while running the test suite), - New optional handler function introduced: reset() This is called after every DML statement to make it easy for a handler to statement specific cleanups. (The only case it's not called is if force the file to be closed) - handler::extra(HA_EXTRA_RESET) is removed. Code that was there before should be moved to handler::reset() - table->read_set contains a bitmap over all columns that are needed in the query. read_row() and similar functions only needs to read these columns - table->write_set contains a bitmap over all columns that will be updated in the query. write_row() and update_row() only needs to update these columns. The above bitmaps should now be up to date in all context (including ALTER TABLE, filesort()). The handler is informed of any changes to the bitmap after fix_fields() by calling the virtual function handler::column_bitmaps_signal(). If the handler does caching of these bitmaps (instead of using table->read_set, table->write_set), it should redo the caching in this code. as the signal() may be sent several times, it's probably best to set a variable in the signal and redo the caching on read_row() / write_row() if the variable was set. - Removed the read_set and write_set bitmap objects from the handler class - Removed all column bit handling functions from the handler class. (Now one instead uses the normal bitmap functions in my_bitmap.c instead of handler dedicated bitmap functions) - field->query_id is removed. One should instead instead check table->read_set and table->write_set if a field is used in the query. - handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now instead use table->read_set to check for which columns to retrieve. - If a handler needs to call Field->val() or Field->store() on columns that are not used in the query, one should install a temporary all-columns-used map while doing so. For this, we provide the following functions: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); field->val(); dbug_tmp_restore_column_map(table->read_set, old_map); and similar for the write map: my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); field->val(); dbug_tmp_restore_column_map(table->write_set, old_map); If this is not done, you will sooner or later hit a DBUG_ASSERT in the field store() / val() functions. (For not DBUG binaries, the dbug_tmp_restore_column_map() and dbug_tmp_restore_column_map() are inline dummy functions and should be optimized away be the compiler). - If one needs to temporary set the column map for all binaries (and not just to avoid the DBUG_ASSERT() in the Field::store() / Field::val() methods) one should use the functions tmp_use_all_columns() and tmp_restore_column_map() instead of the above dbug_ variants. - All 'status' fields in the handler base class (like records, data_file_length etc) are now stored in a 'stats' struct. This makes it easier to know what status variables are provided by the base handler. This requires some trivial variable names in the extra() function. - New virtual function handler::records(). This is called to optimize COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true. (stats.records is not supposed to be an exact value. It's only has to be 'reasonable enough' for the optimizer to be able to choose a good optimization path). - Non virtual handler::init() function added for caching of virtual constants from engine. - Removed has_transactions() virtual method. Now one should instead return HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support transactions. - The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument that is to be used with 'new handler_name()' to allocate the handler in the right area. The xxxx_create_handler() function is also responsible for any initialization of the object before returning. For example, one should change: static handler *myisam_create_handler(TABLE_SHARE *table) { return new ha_myisam(table); } -> static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { return new (mem_root) ha_myisam(table); } - New optional virtual function: use_hidden_primary_key(). This is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined but we don't have a primary key. This allows the handler to take precisions in remembering any hidden primary key to able to update/delete any found row. The default handler marks all columns to be read. - handler::table_flags() now returns a ulonglong (to allow for more flags). - New/changed table_flags() - HA_HAS_RECORDS Set if ::records() is supported - HA_NO_TRANSACTIONS Set if engine doesn't support transactions - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE Set if we should mark all primary key columns for read when reading rows as part of a DELETE statement. If there is no primary key, all columns are marked for read. - HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some cases (based on table->read_set) - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - HA_DUPP_POS Renamed to HA_DUPLICATE_POS - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE Set this if we should mark ALL key columns for read when when reading rows as part of a DELETE statement. In case of an update we will mark all keys for read for which key part changed value. - HA_STATS_RECORDS_IS_EXACT Set this if stats.records is exact. (This saves us some extra records() calls when optimizing COUNT(*)) - Removed table_flags() - HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if handler::records() gives an exact count() and HA_STATS_RECORDS_IS_EXACT if stats.records is exact. - HA_READ_RND_SAME Removed (no one supported this one) - Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk() - Renamed handler::dupp_pos to handler::dup_pos - Removed not used variable handler::sortkey Upper level handler changes: - ha_reset() now does some overall checks and calls ::reset() - ha_table_flags() added. This is a cached version of table_flags(). The cache is updated on engine creation time and updated on open. MySQL level changes (not obvious from the above): - DBUG_ASSERT() added to check that column usage matches what is set in the column usage bit maps. (This found a LOT of bugs in current column marking code). - In 5.1 before, all used columns was marked in read_set and only updated columns was marked in write_set. Now we only mark columns for which we need a value in read_set. - Column bitmaps are created in open_binary_frm() and open_table_from_share(). (Before this was in table.cc) - handler::table_flags() calls are replaced with handler::ha_table_flags() - For calling field->val() you must have the corresponding bit set in table->read_set. For calling field->store() you must have the corresponding bit set in table->write_set. (There are asserts in all store()/val() functions to catch wrong usage) - thd->set_query_id is renamed to thd->mark_used_columns and instead of setting this to an integer value, this has now the values: MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE Changed also all variables named 'set_query_id' to mark_used_columns. - In filesort() we now inform the handler of exactly which columns are needed doing the sort and choosing the rows. - The TABLE_SHARE object has a 'all_set' column bitmap one can use when one needs a column bitmap with all columns set. (This is used for table->use_all_columns() and other places) - The TABLE object has 3 column bitmaps: - def_read_set Default bitmap for columns to be read - def_write_set Default bitmap for columns to be written - tmp_set Can be used as a temporary bitmap when needed. The table object has also two pointer to bitmaps read_set and write_set that the handler should use to find out which columns are used in which way. - count() optimization now calls handler::records() instead of using handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true). - Added extra argument to Item::walk() to indicate if we should also traverse sub queries. - Added TABLE parameter to cp_buffer_from_ref() - Don't close tables created with CREATE ... SELECT but keep them in the table cache. (Faster usage of newly created tables). New interfaces: - table->clear_column_bitmaps() to initialize the bitmaps for tables at start of new statements. - table->column_bitmaps_set() to set up new column bitmaps and signal the handler about this. - table->column_bitmaps_set_no_signal() for some few cases where we need to setup new column bitmaps but don't signal the handler (as the handler has already been signaled about these before). Used for the momement only in opt_range.cc when doing ROR scans. - table->use_all_columns() to install a bitmap where all columns are marked as use in the read and the write set. - table->default_column_bitmaps() to install the normal read and write column bitmaps, but not signaling the handler about this. This is mainly used when creating TABLE instances. - table->mark_columns_needed_for_delete(), table->mark_columns_needed_for_delete() and table->mark_columns_needed_for_insert() to allow us to put additional columns in column usage maps if handler so requires. (The handler indicates what it neads in handler->table_flags()) - table->prepare_for_position() to allow us to tell handler that it needs to read primary key parts to be able to store them in future table->position() calls. (This replaces the table->file->ha_retrieve_all_pk function) - table->mark_auto_increment_column() to tell handler are going to update columns part of any auto_increment key. - table->mark_columns_used_by_index() to mark all columns that is part of an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow it to quickly know that it only needs to read colums that are part of the key. (The handler can also use the column map for detecting this, but simpler/faster handler can just monitor the extra() call). - table->mark_columns_used_by_index_no_reset() to in addition to other columns, also mark all columns that is used by the given key. - table->restore_column_maps_after_mark_index() to restore to default column maps after a call to table->mark_columns_used_by_index(). - New item function register_field_in_read_map(), for marking used columns in table->read_map. Used by filesort() to mark all used columns - Maintain in TABLE->merge_keys set of all keys that are used in query. (Simplices some optimization loops) - Maintain Field->part_of_key_not_clustered which is like Field->part_of_key but the field in the clustered key is not assumed to be part of all index. (used in opt_range.cc for faster loops) - dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map() tmp_use_all_columns() and tmp_restore_column_map() functions to temporally mark all columns as usable. The 'dbug_' version is primarily intended inside a handler when it wants to just call Field:store() & Field::val() functions, but don't need the column maps set for any other usage. (ie:: bitmap_is_set() is never called) - We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set. The reason for this is that if we have a column marked only for write we can't in the MySQL level know if the value changed or not. The reason this worked before was that MySQL marked all to be written columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden bug'. - open_table_from_share() does not anymore setup temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler(). (Simpler, faster code) Bugs fixed: - Column marking was not done correctly in a lot of cases. (ALTER TABLE, when using triggers, auto_increment fields etc) (Could potentially result in wrong values inserted in table handlers relying on that the old column maps or field->set_query_id was correct) Especially when it comes to triggers, there may be cases where the old code would cause lost/wrong values for NDB and/or InnoDB tables. - Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags: OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG. This allowed me to remove some wrong warnings about: "Some non-transactional changed tables couldn't be rolled back" - Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose some warnings about "Some non-transactional changed tables couldn't be rolled back") - Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table() which could cause delete_table to report random failures. - Fixed core dumps for some tests when running with --debug - Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) - slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. - If we get an duplicate row on insert, change column map to read and write all columns while retrying the operation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. - For table handler that doesn't support NULL in keys, we would give an error when creating a primary key with NULL fields, even after the fields has been automaticly converted to NOT NULL. - Creating a primary key on a SPATIAL key, would fail if field was not declared as NOT NULL. Cleanups: - Removed not used condition argument to setup_tables - Removed not needed item function reset_query_id_processor(). - Field->add_index is removed. Now this is instead maintained in (field->flags & FIELD_IN_ADD_INDEX) - Field->fieldnr is removed (use field->field_index instead) - New argument to filesort() to indicate that it should return a set of row pointers (not used columns). This allowed me to remove some references to sql_command in filesort and should also enable us to return column results in some cases where we couldn't before. - Changed column bitmap handling in opt_range.cc to be aligned with TABLE bitmap, which allowed me to use bitmap functions instead of looping over all fields to create some needed bitmaps. (Faster and smaller code) - Broke up found too long lines - Moved some variable declaration at start of function for better code readability. - Removed some not used arguments from functions. (setup_fields(), mysql_prepare_insert_check_table()) - setup_fields() now takes an enum instead of an int for marking columns usage. - For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. - Changed some constants to enum's and define's. - Using separate column read and write sets allows for easier checking of timestamp field was set by statement. - Remove calls to free_io_cache() as this is now done automaticly in ha_reset() - Don't build table->normalized_path as this is now identical to table->path (after bar's fixes to convert filenames) - Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to do comparision with the 'convert-dbug-for-diff' tool. Things left to do in 5.1: - We wrongly log failed CREATE TABLE ... SELECT in some cases when using row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result) Mats has promised to look into this. - Test that my fix for CREATE TABLE ... SELECT is indeed correct. (I added several test cases for this, but in this case it's better that someone else also tests this throughly). Lars has promosed to do this. BitKeeper/etc/ignore: added mysys/test_bitmap include/base64.h: Removed my_global.h, as this must be included first in any program include/heap.h: Added heap_reset() (Required by new handler interface) include/my_base.h: Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET). HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary include/my_bitmap.h: Remove my_pthread.h (should be included at upper level) Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp() Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void include/myisam.h: Added mi_reset() (Required by new handler interface) include/myisammrg.h: Added myrg_reset() (Required by new handler interface) include/mysql_com.h: Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/install_test_db.sh: Simplify ldata usage Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set) mysql-test/mysql-test-run.pl: Added --tmpdir=. to bootstrap mysql-test/mysql-test-run.sh: Use copy instead of INSTALL_DB for master and slave databases. (Speeds up startup time a lot!) Remove snapshot directories at startup (removes some strange warnings) mysql-test/r/binlog_row_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment (This found some bugs that Mats is going to fix shortly) mysql-test/r/binlog_stm_mix_innodb_myisam.result: Added testing of CREATE ... SELECT in a mixed environment mysql-test/r/create.result: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/r/federated.result: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/r/func_gconcat.result: Enable some disabled tests (converted them slightly to be predictable) mysql-test/r/func_time.result: Added drop of test function mysql-test/r/innodb_mysql.result: Added tests for CREATE ... SELECT mysql-test/r/insert.result: More tests Added testing of duplicate columns in insert mysql-test/r/loaddata.result: Added testing LOAD DATA ... SET ... mysql-test/r/multi_update.result: Test multi updates and deletes using primary key and without mysql-test/r/ndb_index_unique.result: Better error message mysql-test/r/ndb_replace.result: New correct result after fixing REPLACE handling with NDB mysql-test/r/rpl_ddl.result: Now we don't get these (wrong) warnings anymore mysql-test/r/view_grant.result: Drop used views mysql-test/t/create.test: Some extra tests of warnings and number of tables opened by CREATE ... SELECT mysql-test/t/federated.test: Drop some left over tables Added testing of multiple table update and multiple table delete (with and without keys) mysql-test/t/func_gconcat.test: Enable some disabled tests (converted them slightly to be predictable) mysql-test/t/func_time.test: Added drop of test function mysql-test/t/innodb_mysql.test: Added tests for CREATE ... SELECT mysql-test/t/insert.test: More tests Added testing of duplicate columns in insert mysql-test/t/loaddata.test: Added testing LOAD DATA ... SET ... mysql-test/t/multi_update.test: Test multi updates and deletes using primary key and without mysql-test/t/view_grant.test: Drop used views mysql-test/valgrind.supp: Added supression of not needed warnings when printing stack trace mysys/base64.c: Include my_global.h first mysys/my_bitmap.c: Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy() Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström) Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed. Changed how mutex is allocated to make 'bitmap_free()' function simpler. mysys/thr_lock.c: Added 0x before thread pointers (for easier comparison of DBUG traces) sql/event.cc: Ensure 'use_all_columns()' is used for event tables Don't print warning that event table is damaged if it doesn't exists. sql/field.cc: Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set (Rest of changes are only indentation cleanups) sql/field.h: Removed Field->query_id (replaced by table->read_set and table->write_set) Removed Field->fieldnr (use Field->field_index instead) Removed Field->add_index (Use Field->flags instead) Add Field->part_of_key_not_clustered (for usage in opt_range.cc) sql/filesort.cc: Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set. This allowed me to remove checking of sql_command. Create a temporary column bitmap for fields that are used by the sorting process. Use column bitmaps instead of query_id sql/ha_berkeley.cc: Update to 'newer' table handler interface sql/ha_berkeley.h: Update to 'newer' table handler interface sql/ha_federated.cc: Update to 'newer' table handler interface Only read columns that are needed from remote server. In case of eq ranges, don't generate two conditions in the WHERE clause (this can still be optimized, but would require a bigger code change) Use 'simpler to use' XXXX_LEN' macros A bit simpler logic in ::write_row() when creating statements. In update, only include test of fields actually read. (This greatly simplifies the queries sent by the federated engine) Similar changes done for delete_row() sql/ha_federated.h: Update to 'newer' table handler interface Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE sql/ha_heap.cc: Update to 'newer' table handler interface sql/ha_heap.h: Update to 'newer' table handler interface sql/ha_innodb.cc: Update to 'newer' table handler interface - Update innobase_create_handler() to new interface - Removed HA_NOT_EXACT_COUNT (not needed) - Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. - Prefixed base status variables with 'stats' - Use table column bitmaps instead of ha_get_bit_in_read_set() - Added ::reset(), with code from ::extra(HA_EXTRA_RESET) - Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as the table->read_set and table->write_set bitmaps now are accurate sql/ha_innodb.h: Update to 'newer' table handler interface - table_flags are now ulonglong - Added reset() method - Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns. - Made build_template() a class function to be able to easier access class variables sql/ha_myisam.cc: Update to 'newer' table handler interface sql/ha_myisam.h: Update to 'newer' table handler interface sql/ha_myisammrg.cc: Update to 'newer' table handler interface sql/ha_myisammrg.h: Update to 'newer' table handler interface sql/ha_ndbcluster.cc: Update to 'newer' table handler interface Fixed use_blob_value() to be accurate In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map Correct dumping of field data with DBUG_DUMP Prefix addresses in DBUG_PRINT with 0x Fixed usage of not initialized memory Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index. sql/ha_ndbcluster.h: Update to 'newer' table handler interface sql/ha_ndbcluster_binlog.cc: Mark usage of all columns in ndbcluster binlog tables false -> FALSE, true -> TRUE Use table->s->all_set instead of creating a temporary bitmap. sql/ha_partition.cc: Update to 'newer' table handler interface Added memroot to initialise_partitions() and related functions to get faster memory allocation. partition_create_handler() is now responsible for initialisation of the partition object Some trivial optimizations and indentation fixes Ensure that table_flags() are up to date Removed documentation for removed HA_EXTRA flags Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance' sql/ha_partition.h: Update to 'newer' table handler interface sql/handler.cc: create_xxx handler now takes MEMROOT as an argument to simplify memory allocation. Much simpler get_new_handler() (Initialization of the object is now handled by the create method for the engine) Moved all allocation of bitmap handling to the TABLE object (in table.cc) Added column_bitmaps_signal() to signal column usage changes. Changed binlog_log_row() to use the exiusting all_set bitmap in the table object. Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset() Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row sql/handler.h: Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME HA_DUPP_POS -> HA_DUPLICATE_POS HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records() HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION Added future row type 'ROW_TYPE_PAGES' Added MEM_ROOT to handlerton 'create' function Added ha_statistics, a structure for all status variable in the base handler class. Moved all status variables in the handler class into a stats structs to improve readability. ha_table_flags() is now a cached (not virtual) version of table_flags() reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own. Renamed dupp_ref to dup_ref Renamed not used handler::sortkey Moved read_set and write_set to TABLE structure handler::init() function added for cacheing of virtual constants from engine. sql/item.cc: Added register_field_in_read_map() for marking used columns in expression. This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting. Initalize value.cs_info.character_set_client to fix core dump bug with --debug set_query_id -> mark_used_columns Mark used columns in read_set OR write_set. sql/item.h: Removed reset_query_id_processor() as it's not needed anymore. Added register_field_in_read_map() Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_cmpfunc.cc: Temporary mark used columns to be read/writable Update Item::walk to new interface sql/item_cmpfunc.h: Added extra argument to Item::walk() to indicate if we should also traverse sub queries. sql/item_func.cc: Update Item::walk() to new interface table_flags() -> ha_table_flags() sql/item_func.h: Update Item::walk() to new interface sql/item_row.cc: Update Item::walk() to new interface sql/item_row.h: Update Item::walk() to new interface sql/item_strfunc.h: Update Item::walk() to new interface sql/item_subselect.cc: Added Item_subselect::walk() (It was a bug it was missing before. Not sure what kind of bugs this could have caused) sql/item_subselect.h: Update Item::walk() to new interface sql/item_sum.cc: Update Item::walk() to new interface Updates for new handler interace sql/item_sum.h: Update Item::walk() to new interface sql/key.cc: Updates for new handler interace sql/log.cc: Mark all columns used for log tables Split options flag Ensured that second argument to trans_register_ha is a bool sql/log_event.cc: Fixed comments to be withing 79 characters Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings Updates for new handler interface Use 0x%lx instead of %p (portability problem) sql/mysql_priv.h: Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback Removed not used 'conds' argument to setup_tables sql/mysqld.cc: Indentation fixes and removed old comment sql/opt_range.cc: Update to new handler and bitmap interface. Fixed calls to cp_buffer_from_ref() and walk() (new argument). Create new temporary bitmaps for ror scans. (Needed because of handler changes and to get more accurate column bitmaps than before) Remove not needed file->ha_reset() call before file->close(). Some trivial optimization and indentation fixes. Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts. Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record. This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling. (This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans) Optimized bitmap handling in ror scans: - Start bitmap at position 0, not 1 - Use same bitmap size as in TABLE - Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table sql/opt_range.h: Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan Added temporary column bitmaps used in ROR scans sql/opt_sum.cc: Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set. sql/protocol.cc: We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user sql/records.cc: Updates for new handler interface sql/set_var.cc: Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags sql/share/errmsg.txt: Fixed wrong sql/sp.cc: Mark that we are using all columns for the proc table Update call to setup_tables() to use new prototype sql/sp_head.cc: Removed QQ comment sql/spatial.cc: Removed wrong QQ comment sql/sql_acl.cc: Mark that we need all columns for acl tables Supply memroot to some 'new' calls. Indentation fixes sql/sql_base.cc: set_query_id removed Ensure we call ha_reset() at end of each statement Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set) Fixed marking of some columns that was not proplerly marked before Maintain in TABLE->merge_keys set of all keys that are used in some way Removed not used 'conds' argument from setup_tables() Remove not used setting of 'dupp_field' in insert_fields() Added missing FN_LIBCHAR in mysql_rm_tmp_tables() (This has probably caused us to not properly remove temporary files after crash) sql/sql_bitmap.h: Added is_overlapping() sql/sql_class.cc: Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log. set_query_id -> mark_used_columns Simpler variable usage in pack_row() (cleanup) Moved some variable declartion at start of function for better code readability sql/sql_class.h: Added enum_mark_columns Updated comments Renamed dupp_field -> dup_field Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE. (This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables) sql/sql_delete.cc: Updates to new handler interface Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires. Call table->prepare_for_position() to tell handler that we are going to call ha_position(). Removed call to free_io_cache(). (io_cache is now removed in ha_reset()). Fixed calls to setup_tables() sql/sql_do.cc: Update call to setup_fields() sql/sql_handler.cc: Tell handler tables to always read all columns. Use temporary column map when storing value in field for later index usage sql/sql_help.cc: Makr all used fields to be read Update call to setup_fields() sql/sql_insert.cc: Tell handler we are going to update the auto_increment column dupp_field -> dup_field Set column usage bits for timestamp field. Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column() Removed not used argument from mysql_prepare_insert_check_table(). If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation. This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled. This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row. Setup new bitmaps for delayed insert rows Remove reseting of next_number_fields as it will be reset on next call to handler_insert() Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE. The issue was that one should not to reset this flag as it may be set by a previous statement. The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional. I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done) Don't close tables created with CREATE ... SELECT but keep them in the table cache. Moved out MY_HOOKS from inside function (better readability) sql/sql_load.cc: Update to use new handler and column marking interface Update using setup_tables() sql/sql_olap.cc: Update calls to setup_tables Use enums instead of constants to setup_fields() sql/sql_parse.cc: Handle OPTION_KEEP_LOG: - Set it on CREATE TEMPORARY TABLE / DROP TABLE - Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset - Don't set it for CREATE ... SELECT (this is handled in select_create class) Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset. If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands sql/sql_partition.cc: Update walk() usage Trivial indentation fixes sql/sql_plugin.cc: Mark all columns as used for plugins sql/sql_prepare.cc: Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly) Updates for new handler interface Update calls to setup_fields() sql/sql_repl.cc: Indentation fixes sql/sql_select.cc: Update call to setup_tables() and setup_fields() Remove some old disabled code Update to new hadler interface Indentation cleanups Added column bitmaps for temporary tables. Remove updating of the removed slots in the Field class Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps) For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution. sql/sql_select.h: Indentaition fixes. Install temporary column usage maps when needed Added TABLE element to cp_buffer_from_ref() sql/sql_show.cc: Update to new handler interface Mark all columns used for internal tables. Style fixes. Added support for 'future' ROW_TYPE_PAGES. Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly. sql/sql_table.cc: Update to new handler interface Simple my_snprintf -> strmake() Changed some constants to defines Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL) Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX Mark all columns as used for ALTER TABLE Style fixes Update call to filesort() sql/sql_trigger.h: Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in. sql/sql_udf.cc: Mark all columns as used for udf system table. sql/sql_union.cc: Update call to walk() Update to new handler interface sql/sql_update.cc: Remove query_id argument from compare_record() Use column bitmaps instead of query_id. We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value. Update call to setup_fields() Using separate column read and write sets allows for easier checking of timestamp field was set by statement. Removed call to free_io_cache() as this is now done in ha_reset() Call table->mark_columns_needed_for_update() and table->prepare_for_position() Style fixes sql/sql_view.cc: Style fixes sql/table.cc: Remove implicitely include 'errno.h' Remove code for building normalized path, as this is now identical to 'path' Remove field->fieldnr Added update of field->part_of_key_not_clustered() Create column bitmaps in TABLE and TABLE_SHARE Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler() Update to new handler interface Update call to walk() Added new functions: - st_table::clear_column_bitmaps() - st_table::prepare_for_position() - st_table::mark_columns_used_by_index() - st_table::restore_column_maps_after_mark_index() - st_table::mark_columns_used_by_index_no_reset() - st_table::mark_auto_increment_column() - st_table::mark_columns_needed_for_delete() - st_table::mark_columns_needed_for_update() - st_table::mark_columns_needed_for_insert() sql/table.h: Moved column usage bitmaps from handler to TABLE Added to TABLE_SHARE all_set and column_bitmap_size Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set. Declared all new table column bitmap functions Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps() Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val(). sql/tztime.cc: Mark all columns as used for timezone tables storage/archive/ha_archive.cc: Update to new handler interface storage/archive/ha_archive.h: Update to new handler interface storage/blackhole/ha_blackhole.cc: Update to new handler interface storage/blackhole/ha_blackhole.h: Update to new handler interface removed not needed flag HA_DUPP_POS storage/csv/ha_tina.cc: Update to new handler interface storage/csv/ha_tina.h: Update to new handler interface storage/example/ha_example.cc: Update to new handler interface storage/example/ha_example.h: Update to new handler interface storage/heap/hp_extra.c: Added heap_reset() (Required by new handler interface) storage/heap/hp_test2.c: Use heap_reset() storage/myisam/ft_boolean_search.c: Fixed compiler warning storage/myisam/mi_extra.c: Added mi_reset() (Required by new handler interface) storage/myisam/mi_search.c: Fixed DBUG_PRINT messages to use 0x%lx instead of %lx storage/myisam/mi_test2.c: Use mi_reset() storage/myisam/myisampack.c: Use mi_reset() storage/myisammrg/myrg_extra.c: Added myrg_reset() (Required by new handler interface) unittest/mysys/base64.t.c: Include my_global.h Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
substitution->walk(&Item::remove_dependence_processor, 0,
WL#3817: Simplify string / memory area types and make things more consistent (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c BitKeeper/etc/ignore: added libmysqld/ha_ndbcluster_cond.cc --- added debian/defs.mk debian/control client/completion_hash.cc: Remove not needed casts client/my_readline.h: Remove some old types client/mysql.cc: Simplify types client/mysql_upgrade.c: Remove some old types Update call to dirname_part client/mysqladmin.cc: Remove some old types client/mysqlbinlog.cc: Remove some old types Change some buffers to be uchar to avoid casts client/mysqlcheck.c: Remove some old types client/mysqldump.c: Remove some old types Remove some not needed casts Change some string lengths to size_t client/mysqlimport.c: Remove some old types client/mysqlshow.c: Remove some old types client/mysqlslap.c: Remove some old types Remove some not needed casts client/mysqltest.c: Removed some old types Removed some not needed casts Updated hash-get-key function arguments Updated parameters to dirname_part() client/readline.cc: Removed some old types Removed some not needed casts Changed some string lengths to use size_t client/sql_string.cc: Removed some old types dbug/dbug.c: Removed some old types Changed some string lengths to use size_t Changed some prototypes to avoid casts extra/comp_err.c: Removed some old types extra/innochecksum.c: Removed some old types extra/my_print_defaults.c: Removed some old types extra/mysql_waitpid.c: Removed some old types extra/perror.c: Removed some old types extra/replace.c: Removed some old types Updated parameters to dirname_part() extra/resolve_stack_dump.c: Removed some old types extra/resolveip.c: Removed some old types include/config-win.h: Removed some old types include/decimal.h: Changed binary strings to be uchar* instead of char* include/ft_global.h: Removed some old types include/hash.h: Removed some old types include/heap.h: Removed some old types Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable include/keycache.h: Removed some old types include/m_ctype.h: Removed some old types Changed some string lengths to use size_t Changed character length functions to return uint unsigned char -> uchar include/m_string.h: Removed some old types Changed some string lengths to use size_t include/my_alloc.h: Changed some string lengths to use size_t include/my_base.h: Removed some old types include/my_dbug.h: Removed some old types Changed some string lengths to use size_t Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage include/my_getopt.h: Removed some old types include/my_global.h: Removed old types: my_size_t -> size_t byte -> uchar gptr -> uchar * include/my_list.h: Removed some old types include/my_nosys.h: Removed some old types include/my_pthread.h: Removed some old types include/my_sys.h: Removed some old types Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read() Changed some string lengths to use size_t my_malloc() / my_free() now uses void * Updated parameters to dirname_part() & my_uncompress() include/my_tree.h: Removed some old types include/my_trie.h: Removed some old types include/my_user.h: Changed some string lengths to use size_t include/my_vle.h: Removed some old types include/my_xml.h: Removed some old types Changed some string lengths to use size_t include/myisam.h: Removed some old types include/myisammrg.h: Removed some old types include/mysql.h: Removed some old types Changed byte streams to use uchar* instead of char* include/mysql_com.h: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts include/queues.h: Removed some old types include/sql_common.h: Removed some old types include/sslopt-longopts.h: Removed some old types include/violite.h: Removed some old types Changed some string lengths to use size_t libmysql/client_settings.h: Removed some old types libmysql/libmysql.c: Removed some old types libmysql/manager.c: Removed some old types libmysqld/emb_qcache.cc: Removed some old types libmysqld/emb_qcache.h: Removed some old types libmysqld/lib_sql.cc: Removed some old types Removed some not needed casts Changed some buffers to be uchar* to avoid casts true -> TRUE, false -> FALSE mysys/array.c: Removed some old types mysys/charset.c: Changed some string lengths to use size_t mysys/checksum.c: Include zlib to get definition for crc32 Removed some old types mysys/default.c: Removed some old types Changed some string lengths to use size_t mysys/default_modify.c: Changed some string lengths to use size_t Removed some not needed casts mysys/hash.c: Removed some old types Changed some string lengths to use size_t Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function. hash_element now takes 'ulong' as the index type (cleanup) mysys/list.c: Removed some old types mysys/mf_cache.c: Changed some string lengths to use size_t mysys/mf_dirname.c: Removed some old types Changed some string lengths to use size_t Added argument to dirname_part() to avoid calculation of length for 'to' mysys/mf_fn_ext.c: Removed some old types Updated parameters to dirname_part() mysys/mf_format.c: Removed some old types Changed some string lengths to use size_t mysys/mf_getdate.c: Removed some old types mysys/mf_iocache.c: Removed some old types Changed some string lengths to use size_t Changed calculation of 'max_length' to be done the same way in all functions mysys/mf_iocache2.c: Removed some old types Changed some string lengths to use size_t Clean up comments Removed not needed indentation mysys/mf_keycache.c: Removed some old types mysys/mf_keycaches.c: Removed some old types mysys/mf_loadpath.c: Removed some old types mysys/mf_pack.c: Removed some old types Changed some string lengths to use size_t Removed some not needed casts Removed very old VMS code Updated parameters to dirname_part() Use result of dirnam_part() to remove call to strcat() mysys/mf_path.c: Removed some old types mysys/mf_radix.c: Removed some old types mysys/mf_same.c: Removed some old types mysys/mf_sort.c: Removed some old types mysys/mf_soundex.c: Removed some old types mysys/mf_strip.c: Removed some old types mysys/mf_tempdir.c: Removed some old types mysys/mf_unixpath.c: Removed some old types mysys/mf_wfile.c: Removed some old types mysys/mulalloc.c: Removed some old types mysys/my_alloc.c: Removed some old types Changed some string lengths to use size_t Use void* as type for allocated memory area Removed some not needed casts Changed argument 'Size' to 'length' according coding guidelines mysys/my_chsize.c: Changed some buffers to be uchar* to avoid casts mysys/my_compress.c: More comments Removed some old types Changed string lengths to use size_t Changed arguments to my_uncompress() to make them easier to understand Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) Changed type of 'pack_data' argument to packfrm() to avoid casts. mysys/my_conio.c: Changed some string lengths to use size_t mysys/my_create.c: Removed some old types mysys/my_div.c: Removed some old types mysys/my_error.c: Removed some old types mysys/my_fopen.c: Removed some old types mysys/my_fstream.c: Removed some old types Changed some string lengths to use size_t writen -> written mysys/my_getopt.c: Removed some old types mysys/my_getwd.c: Removed some old types More comments mysys/my_init.c: Removed some old types mysys/my_largepage.c: Removed some old types Changed some string lengths to use size_t mysys/my_lib.c: Removed some old types mysys/my_lockmem.c: Removed some old types mysys/my_malloc.c: Removed some old types Changed malloc(), free() and related functions to use void * Changed all functions to use size_t mysys/my_memmem.c: Indentation cleanup mysys/my_once.c: Removed some old types Changed malloc(), free() and related functions to use void * mysys/my_open.c: Removed some old types mysys/my_pread.c: Removed some old types Changed all functions to use size_t Added comment for how my_pread() / my_pwrite() are supposed to work. Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. (If we ever would really need this, it should be enabled only with a flag argument) mysys/my_quick.c: Removed some old types Changed all functions to use size_t mysys/my_read.c: Removed some old types Changed all functions to use size_t mysys/my_realloc.c: Removed some old types Use void* as type for allocated memory area Changed all functions to use size_t mysys/my_static.c: Removed some old types mysys/my_static.h: Removed some old types mysys/my_vle.c: Removed some old types mysys/my_wincond.c: Removed some old types mysys/my_windac.c: Removed some old types mysys/my_write.c: Removed some old types Changed all functions to use size_t mysys/ptr_cmp.c: Removed some old types Changed all functions to use size_t mysys/queues.c: Removed some old types mysys/safemalloc.c: Removed some old types Changed malloc(), free() and related functions to use void * Changed all functions to use size_t mysys/string.c: Removed some old types Changed all functions to use size_t mysys/testhash.c: Removed some old types mysys/thr_alarm.c: Removed some old types mysys/thr_lock.c: Removed some old types mysys/tree.c: Removed some old types mysys/trie.c: Removed some old types mysys/typelib.c: Removed some old types plugin/daemon_example/daemon_example.cc: Removed some old types regex/reginit.c: Removed some old types server-tools/instance-manager/buffer.cc: Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/buffer.h: Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/commands.cc: Removed some old types Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/instance_map.cc: Removed some old types Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/instance_options.cc: Changed buffer to be of type uchar* Replaced alloc_root + strcpy() with strdup_root() server-tools/instance-manager/mysql_connection.cc: Changed buffer to be of type uchar* server-tools/instance-manager/options.cc: Removed some old types server-tools/instance-manager/parse.cc: Changed some string lengths to use size_t server-tools/instance-manager/parse.h: Removed some old types Changed some string lengths to use size_t server-tools/instance-manager/protocol.cc: Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t server-tools/instance-manager/protocol.h: Changed some string lengths to use size_t server-tools/instance-manager/user_map.cc: Removed some old types Changed some string lengths to use size_t sql/derror.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/discover.cc: Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts sql/event_data_objects.cc: Removed some old types Added missing casts for alloc() and sprintf() sql/event_db_repository.cc: Changed some buffers to be uchar* to avoid casts Added missing casts for sprintf() sql/event_queue.cc: Removed some old types sql/field.cc: Removed some old types Changed memory buffers to be uchar* Changed some string lengths to use size_t Removed a lot of casts Safety fix in Field_blob::val_decimal() to not access zero pointer sql/field.h: Removed some old types Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes). Changed some string lengths to use size_t Removed some not needed casts Changed val_xxx(xxx, new_ptr) to take const pointers sql/field_conv.cc: Removed some old types Added casts required because memory area pointers are now uchar* sql/filesort.cc: Initalize variable that was used unitialized in error conditions sql/gen_lex_hash.cc: Removed some old types Changed memory buffers to be uchar* Changed some string lengths to use size_t Removed a lot of casts Safety fix in Field_blob::val_decimal() to not access zero pointer sql/gstream.h: Added required cast sql/ha_ndbcluster.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts Added required casts Removed some not needed casts sql/ha_ndbcluster.h: Removed some old types sql/ha_ndbcluster_binlog.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake() Changed some string lengths to use size_t Added missing casts for alloc() and sprintf() sql/ha_ndbcluster_binlog.h: Removed some old types sql/ha_ndbcluster_cond.cc: Removed some old types Removed some not needed casts sql/ha_ndbcluster_cond.h: Removed some old types sql/ha_partition.cc: Removed some old types Changed prototype for change_partition() to avoid casts sql/ha_partition.h: Removed some old types sql/handler.cc: Removed some old types Changed some string lengths to use size_t sql/handler.h: Removed some old types Changed some string lengths to use size_t Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts sql/hash_filo.h: Removed some old types Changed all functions to use size_t sql/hostname.cc: Removed some old types sql/item.cc: Removed some old types Changed some string lengths to use size_t Use strmake() instead of memdup() to create a null terminated string. Updated calls to new Field() sql/item.h: Removed some old types Changed malloc(), free() and related functions to use void * Changed some buffers to be uchar* to avoid casts sql/item_cmpfunc.cc: Removed some old types Changed some buffers to be uchar* to avoid casts sql/item_cmpfunc.h: Removed some old types sql/item_create.cc: Removed some old types sql/item_func.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added test for failing alloc() in init_result_field() Remove old confusing comment Fixed compiler warning sql/item_func.h: Removed some old types sql/item_row.cc: Removed some old types sql/item_row.h: Removed some old types sql/item_strfunc.cc: Include zlib (needed becasue we call crc32) Removed some old types sql/item_strfunc.h: Removed some old types Changed some types to match new function prototypes sql/item_subselect.cc: Removed some old types sql/item_subselect.h: Removed some old types sql/item_sum.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/item_sum.h: Removed some old types sql/item_timefunc.cc: Removed some old types Changed some string lengths to use size_t sql/item_timefunc.h: Removed some old types sql/item_xmlfunc.cc: Changed some string lengths to use size_t sql/item_xmlfunc.h: Removed some old types sql/key.cc: Removed some old types Removed some not needed casts sql/lock.cc: Removed some old types Added some cast to my_multi_malloc() arguments for safety sql/log.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Changed usage of pwrite() to not assume it holds the cursor position for the file Made usage of my_read() safer sql/log_event.cc: Removed some old types Added checking of return value of malloc() in pack_info() Changed some buffers to be uchar* to avoid casts Removed some 'const' to avoid casts Added missing casts for alloc() and sprintf() Added required casts Removed some not needed casts Added some cast to my_multi_malloc() arguments for safety sql/log_event.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/log_event_old.cc: Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/log_event_old.h: Changed some buffers to be uchar* to avoid casts sql/mf_iocache.cc: Removed some old types sql/my_decimal.cc: Changed memory area to use uchar* sql/my_decimal.h: Changed memory area to use uchar* sql/mysql_priv.h: Removed some old types Changed malloc(), free() and related functions to use void * Changed some string lengths to use size_t Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow Changed some buffers to be uchar* to avoid casts sql/mysqld.cc: Removed some old types sql/net_serv.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Ensure that vio_read()/vio_write() return values are stored in a size_t variable Removed some not needed casts sql/opt_range.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/opt_range.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/opt_sum.cc: Removed some old types Removed some not needed casts sql/parse_file.cc: Removed some old types Changed some string lengths to use size_t Changed alloc_root + memcpy + set end 0 -> strmake_root() sql/parse_file.h: Removed some old types sql/partition_info.cc: Removed some old types Added missing casts for alloc() Changed some buffers to be uchar* to avoid casts sql/partition_info.h: Changed some buffers to be uchar* to avoid casts sql/protocol.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/protocol.h: Removed some old types Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/records.cc: Removed some old types sql/repl_failsafe.cc: Removed some old types Changed some string lengths to use size_t Added required casts sql/rpl_filter.cc: Removed some old types Updated hash-get-key function arguments Changed some string lengths to use size_t sql/rpl_filter.h: Changed some string lengths to use size_t sql/rpl_injector.h: Removed some old types sql/rpl_record.cc: Removed some old types Removed some not needed casts Changed some buffers to be uchar* to avoid casts sql/rpl_record.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/rpl_record_old.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/rpl_record_old.h: Removed some old types Changed some buffers to be uchar* to avoid cast sql/rpl_rli.cc: Removed some old types sql/rpl_tblmap.cc: Removed some old types sql/rpl_tblmap.h: Removed some old types sql/rpl_utility.cc: Removed some old types sql/rpl_utility.h: Removed some old types Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length sql/set_var.cc: Removed some old types Updated parameters to dirname_part() sql/set_var.h: Removed some old types sql/slave.cc: Removed some old types Changed some string lengths to use size_t sql/slave.h: Removed some old types sql/sp.cc: Removed some old types Added missing casts for printf() sql/sp.h: Removed some old types Updated hash-get-key function arguments sql/sp_cache.cc: Removed some old types Added missing casts for printf() Updated hash-get-key function arguments sql/sp_head.cc: Removed some old types Added missing casts for alloc() and printf() Added required casts Updated hash-get-key function arguments sql/sp_head.h: Removed some old types sql/sp_pcontext.cc: Removed some old types sql/sp_pcontext.h: Removed some old types sql/sql_acl.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added required casts sql/sql_analyse.cc: Changed some buffers to be uchar* to avoid casts sql/sql_analyse.h: Changed some buffers to be uchar* to avoid casts sql/sql_array.h: Removed some old types sql/sql_base.cc: Removed some old types Updated hash-get-key function arguments sql/sql_binlog.cc: Removed some old types Added missing casts for printf() sql/sql_cache.cc: Removed some old types Updated hash-get-key function arguments Removed some not needed casts Changed some string lengths to use size_t sql/sql_cache.h: Removed some old types Removed reference to not existing function cache_key() Updated hash-get-key function arguments sql/sql_class.cc: Removed some old types Updated hash-get-key function arguments Added missing casts for alloc() Updated hash-get-key function arguments Moved THD::max_row_length() to table.cc (as it's not depending on THD) Removed some not needed casts sql/sql_class.h: Removed some old types Changed malloc(), free() and related functions to use void * Removed some not needed casts Changed some string lengths to use size_t Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD sql/sql_connect.cc: Removed some old types Added required casts sql/sql_db.cc: Removed some old types Removed some not needed casts Added some cast to my_multi_malloc() arguments for safety Added missing casts for alloc() sql/sql_delete.cc: Removed some old types sql/sql_handler.cc: Removed some old types Updated hash-get-key function arguments Added some cast to my_multi_malloc() arguments for safety sql/sql_help.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_insert.cc: Removed some old types Added missing casts for alloc() and printf() sql/sql_lex.cc: Removed some old types sql/sql_lex.h: Removed some old types Removed some not needed casts sql/sql_list.h: Removed some old types Removed some not needed casts sql/sql_load.cc: Removed some old types Removed compiler warning sql/sql_manager.cc: Removed some old types sql/sql_map.cc: Removed some old types sql/sql_map.h: Removed some old types sql/sql_olap.cc: Removed some old types sql/sql_parse.cc: Removed some old types Trivial move of code lines to make things more readable Changed some string lengths to use size_t Added missing casts for alloc() sql/sql_partition.cc: Removed some old types Removed compiler warnings about not used functions Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_partition.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/sql_plugin.cc: Removed some old types Added missing casts for alloc() Updated hash-get-key function arguments sql/sql_prepare.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Added missing casts for alloc() and printf() sql-common/client.c: Removed some old types Changed some memory areas to use uchar* sql-common/my_user.c: Changed some string lengths to use size_t sql-common/pack.c: Changed some buffers to be uchar* to avoid casts sql/sql_repl.cc: Added required casts Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/sql_select.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some old types sql/sql_select.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/sql_servers.cc: Removed some old types Updated hash-get-key function arguments sql/sql_show.cc: Removed some old types Added missing casts for alloc() Removed some not needed casts sql/sql_string.cc: Removed some old types Added required casts sql/sql_table.cc: Removed some old types Removed compiler warning about not used variable Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_test.cc: Removed some old types sql/sql_trigger.cc: Removed some old types Added missing casts for alloc() sql/sql_udf.cc: Removed some old types Updated hash-get-key function arguments sql/sql_union.cc: Removed some old types sql/sql_update.cc: Removed some old types Removed some not needed casts sql/sql_view.cc: Removed some old types sql/sql_yacc.yy: Removed some old types Changed some string lengths to use size_t Added missing casts for alloc() sql/stacktrace.c: Removed some old types sql/stacktrace.h: Removed some old types sql/structs.h: Removed some old types sql/table.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts Removed setting of LEX_STRING() arguments in declaration Added required casts More function comments Moved max_row_length() here from sql_class.cc/sql_class.h sql/table.h: Removed some old types Changed some string lengths to use size_t sql/thr_malloc.cc: Use void* as type for allocated memory area Changed all functions to use size_t sql/tzfile.h: Changed some buffers to be uchar* to avoid casts sql/tztime.cc: Changed some buffers to be uchar* to avoid casts Updated hash-get-key function arguments Added missing casts for alloc() Removed some not needed casts sql/uniques.cc: Removed some old types Removed some not needed casts sql/unireg.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added missing casts for alloc() storage/archive/archive_reader.c: Removed some old types storage/archive/azio.c: Removed some old types Removed some not needed casts storage/archive/ha_archive.cc: Removed some old types Changed type for 'frmblob' in archive_discover() to match handler Updated hash-get-key function arguments Removed some not needed casts storage/archive/ha_archive.h: Removed some old types storage/blackhole/ha_blackhole.cc: Removed some old types storage/blackhole/ha_blackhole.h: Removed some old types storage/csv/ha_tina.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts storage/csv/ha_tina.h: Removed some old types Removed some not needed casts storage/csv/transparent_file.cc: Removed some old types Changed type of 'bytes_read' to be able to detect read errors Fixed indentation storage/csv/transparent_file.h: Removed some old types storage/example/ha_example.cc: Removed some old types Updated hash-get-key function arguments storage/example/ha_example.h: Removed some old types storage/federated/ha_federated.cc: Removed some old types Updated hash-get-key function arguments Removed some not needed casts storage/federated/ha_federated.h: Removed some old types storage/heap/_check.c: Changed some buffers to be uchar* to avoid casts storage/heap/_rectest.c: Removed some old types storage/heap/ha_heap.cc: Removed some old types storage/heap/ha_heap.h: Removed some old types storage/heap/heapdef.h: Removed some old types storage/heap/hp_block.c: Removed some old types Changed some string lengths to use size_t storage/heap/hp_clear.c: Removed some old types storage/heap/hp_close.c: Removed some old types storage/heap/hp_create.c: Removed some old types storage/heap/hp_delete.c: Removed some old types storage/heap/hp_hash.c: Removed some old types storage/heap/hp_info.c: Removed some old types storage/heap/hp_open.c: Removed some old types storage/heap/hp_rfirst.c: Removed some old types storage/heap/hp_rkey.c: Removed some old types storage/heap/hp_rlast.c: Removed some old types storage/heap/hp_rnext.c: Removed some old types storage/heap/hp_rprev.c: Removed some old types storage/heap/hp_rrnd.c: Removed some old types storage/heap/hp_rsame.c: Removed some old types storage/heap/hp_scan.c: Removed some old types storage/heap/hp_test1.c: Removed some old types storage/heap/hp_test2.c: Removed some old types storage/heap/hp_update.c: Removed some old types storage/heap/hp_write.c: Removed some old types Changed some string lengths to use size_t storage/innobase/handler/ha_innodb.cc: Removed some old types Updated hash-get-key function arguments Added missing casts for alloc() and printf() Removed some not needed casts storage/innobase/handler/ha_innodb.h: Removed some old types storage/myisam/ft_boolean_search.c: Removed some old types storage/myisam/ft_nlq_search.c: Removed some old types storage/myisam/ft_parser.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/ft_static.c: Removed some old types storage/myisam/ft_stopwords.c: Removed some old types storage/myisam/ft_update.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/ftdefs.h: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/fulltext.h: Removed some old types storage/myisam/ha_myisam.cc: Removed some old types storage/myisam/ha_myisam.h: Removed some old types storage/myisam/mi_cache.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/mi_check.c: Removed some old types storage/myisam/mi_checksum.c: Removed some old types storage/myisam/mi_close.c: Removed some old types storage/myisam/mi_create.c: Removed some old types storage/myisam/mi_delete.c: Removed some old types storage/myisam/mi_delete_all.c: Removed some old types storage/myisam/mi_dynrec.c: Removed some old types storage/myisam/mi_extra.c: Removed some old types storage/myisam/mi_key.c: Removed some old types storage/myisam/mi_locking.c: Removed some old types storage/myisam/mi_log.c: Removed some old types storage/myisam/mi_open.c: Removed some old types Removed some not needed casts Check argument of my_write()/my_pwrite() in functions returning int Added casting of string lengths to size_t storage/myisam/mi_packrec.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/mi_page.c: Removed some old types storage/myisam/mi_preload.c: Removed some old types storage/myisam/mi_range.c: Removed some old types storage/myisam/mi_rfirst.c: Removed some old types storage/myisam/mi_rkey.c: Removed some old types storage/myisam/mi_rlast.c: Removed some old types storage/myisam/mi_rnext.c: Removed some old types storage/myisam/mi_rnext_same.c: Removed some old types storage/myisam/mi_rprev.c: Removed some old types storage/myisam/mi_rrnd.c: Removed some old types storage/myisam/mi_rsame.c: Removed some old types storage/myisam/mi_rsamepos.c: Removed some old types storage/myisam/mi_scan.c: Removed some old types storage/myisam/mi_search.c: Removed some old types storage/myisam/mi_static.c: Removed some old types storage/myisam/mi_statrec.c: Removed some old types storage/myisam/mi_test1.c: Removed some old types storage/myisam/mi_test2.c: Removed some old types storage/myisam/mi_test3.c: Removed some old types storage/myisam/mi_unique.c: Removed some old types storage/myisam/mi_update.c: Removed some old types storage/myisam/mi_write.c: Removed some old types storage/myisam/myisam_ftdump.c: Removed some old types storage/myisam/myisamchk.c: Removed some old types storage/myisam/myisamdef.h: Removed some old types storage/myisam/myisamlog.c: Removed some old types Indentation fix storage/myisam/myisampack.c: Removed some old types storage/myisam/rt_index.c: Removed some old types storage/myisam/rt_split.c: Removed some old types storage/myisam/sort.c: Removed some old types storage/myisam/sp_defs.h: Removed some old types storage/myisam/sp_key.c: Removed some old types storage/myisammrg/ha_myisammrg.cc: Removed some old types storage/myisammrg/ha_myisammrg.h: Removed some old types storage/myisammrg/myrg_close.c: Removed some old types storage/myisammrg/myrg_def.h: Removed some old types storage/myisammrg/myrg_delete.c: Removed some old types storage/myisammrg/myrg_open.c: Removed some old types Updated parameters to dirname_part() storage/myisammrg/myrg_queue.c: Removed some old types storage/myisammrg/myrg_rfirst.c: Removed some old types storage/myisammrg/myrg_rkey.c: Removed some old types storage/myisammrg/myrg_rlast.c: Removed some old types storage/myisammrg/myrg_rnext.c: Removed some old types storage/myisammrg/myrg_rnext_same.c: Removed some old types storage/myisammrg/myrg_rprev.c: Removed some old types storage/myisammrg/myrg_rrnd.c: Removed some old types storage/myisammrg/myrg_rsame.c: Removed some old types storage/myisammrg/myrg_update.c: Removed some old types storage/myisammrg/myrg_write.c: Removed some old types storage/ndb/include/util/ndb_opts.h: Removed some old types storage/ndb/src/cw/cpcd/main.cpp: Removed some old types storage/ndb/src/kernel/vm/Configuration.cpp: Removed some old types storage/ndb/src/mgmclient/main.cpp: Removed some old types storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Removed some old types Removed old disabled code storage/ndb/src/mgmsrv/main.cpp: Removed some old types storage/ndb/src/ndbapi/NdbBlob.cpp: Removed some old types storage/ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variable storage/ndb/src/ndbapi/NdbOperationInt.cpp: Added required casts storage/ndb/src/ndbapi/NdbScanOperation.cpp: Added required casts storage/ndb/tools/delete_all.cpp: Removed some old types storage/ndb/tools/desc.cpp: Removed some old types storage/ndb/tools/drop_index.cpp: Removed some old types storage/ndb/tools/drop_tab.cpp: Removed some old types storage/ndb/tools/listTables.cpp: Removed some old types storage/ndb/tools/ndb_config.cpp: Removed some old types storage/ndb/tools/restore/consumer_restore.cpp: Changed some buffers to be uchar* to avoid casts with new defintion of packfrm() storage/ndb/tools/restore/restore_main.cpp: Removed some old types storage/ndb/tools/select_all.cpp: Removed some old types storage/ndb/tools/select_count.cpp: Removed some old types storage/ndb/tools/waiter.cpp: Removed some old types strings/bchange.c: Changed function to use uchar * and size_t strings/bcmp.c: Changed function to use uchar * and size_t strings/bmove512.c: Changed function to use uchar * and size_t strings/bmove_upp.c: Changed function to use uchar * and size_t strings/ctype-big5.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-bin.c: Changed functions to use size_t strings/ctype-cp932.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-czech.c: Fixed indentation Changed functions to use size_t strings/ctype-euc_kr.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-eucjpms.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-gb2312.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-gbk.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-latin1.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-mb.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-simple.c: Changed functions to use size_t Simpler loops for caseup/casedown unsigned int -> uint unsigned char -> uchar strings/ctype-sjis.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-tis620.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-uca.c: Changed functions to use size_t unsigned char -> uchar strings/ctype-ucs2.c: Moved inclusion of stdarg.h to other includes usigned char -> uchar Changed functions to use size_t Changed character length functions to return uint strings/ctype-ujis.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-utf8.c: Changed functions to use size_t unsigned char -> uchar Indentation fixes strings/ctype-win1250ch.c: Indentation fixes Changed functions to use size_t strings/ctype.c: Changed functions to use size_t strings/decimal.c: Changed type for memory argument to uchar * strings/do_ctype.c: Indentation fixes strings/my_strtoll10.c: unsigned char -> uchar strings/my_vsnprintf.c: Changed functions to use size_t strings/r_strinstr.c: Removed some old types Changed functions to use size_t strings/str_test.c: Removed some old types strings/strappend.c: Changed functions to use size_t strings/strcont.c: Removed some old types strings/strfill.c: Removed some old types strings/strinstr.c: Changed functions to use size_t strings/strlen.c: Changed functions to use size_t strings/strmake.c: Changed functions to use size_t strings/strnlen.c: Changed functions to use size_t strings/strnmov.c: Changed functions to use size_t strings/strto.c: unsigned char -> uchar strings/strtod.c: Changed functions to use size_t strings/strxnmov.c: Changed functions to use size_t strings/xml.c: Changed functions to use size_t Indentation fixes tests/mysql_client_test.c: Removed some old types tests/thread_test.c: Removed some old types vio/test-ssl.c: Removed some old types vio/test-sslclient.c: Removed some old types vio/test-sslserver.c: Removed some old types vio/vio.c: Removed some old types vio/vio_priv.h: Removed some old types Changed vio_read()/vio_write() to work with size_t vio/viosocket.c: Changed vio_read()/vio_write() to work with size_t Indentation fixes vio/viossl.c: Changed vio_read()/vio_write() to work with size_t Indentation fixes vio/viosslfactories.c: Removed some old types vio/viotest-ssl.c: Removed some old types win/README: More explanations
2007-05-10 11:59:39 +02:00
(uchar *) select_lex->outer_select());
}
DBUG_RETURN(false);
}
merge with 4.1 BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/triggers/post-commit: Auto merged Docs/Support/texi2html: Auto merged Makefile.am: Auto merged client/Makefile.am: Auto merged client/mysql.cc: Auto merged client/mysqldump.c: Auto merged include/my_base.h: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/my_time.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/buf/buf0buf.c: Auto merged innobase/include/row0mysql.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/examples/Makefile.am: Auto merged myisam/mi_check.c: Auto merged mysql-test/include/ps_modify.inc: Auto merged mysql-test/install_test_db.sh: Auto merged mysql-test/r/alter_table.result: Auto merged mysql-test/r/auto_increment.result: Auto merged mysql-test/r/bdb.result: Auto merged mysql-test/r/ctype_latin1_de.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_if.result: Auto merged mysql-test/t/derived.test: Auto merged mysql-test/t/insert.test: merge with 4.1 Fixed test case to not use 'if exists' when it shouldn't mysql-test/t/range.test: merge with 4.1 Added missing drop table sql/ha_ndbcluster.cc: merge with 4.1 Simple optimization: use max() instead of ? : sql/item_func.cc: merge with 4.1 (Added back old variable names for easier merges) sql/opt_range.cc: merge with 4.1 Removed argument 'parent_alloc' from QUICK_RANGE_SELECT as this was not used Added assert if using QUICK_GROUP_MIN_MAX_SELECT with parent_alloc as the init() function can't handle this Changed back get_quick_select_for_ref() to use it's own alloc root becasue this function may be called several times for one query sql/sql_handler.cc: merge with 4.1 change variable 'err' to 'error' as same function had a label named 'err' sql/sql_update.cc: Use multi-update code from 5.0 instead of 4.1 We will fix the locking code shortly in 5.0 to be faster than in 4.1
2004-10-29 18:26:52 +02:00
void Item_singlerow_subselect::store(uint i, Item *item)
{
row[i]->store(item);
Bug#34384: Slow down on constant conversion. When values of different types are compared they're converted to a type that allows correct comparison. This conversion is done for each comparison and takes some time. When a constant is being compared it's possible to cache the value after conversion to speedup comparison. In some cases (large dataset, complex WHERE condition with many type conversions) query might be executed 7% faster. A test case isn't provided because all changes are internal and isn't visible outside. The behavior of the Item_cache is changed to cache values on the first request of cached value rather than at the moment of storing item to be cached. A flag named value_cached is added to the Item_cache class. It's set to TRUE when cache holds the value of the last stored item. Function named cache_value() is added to the Item_cache class and derived classes. This function actually caches the value of the saved item. Item_cache_xxx::store functions now only store item to be cached and set value_cached flag to FALSE. Item_cache_xxx::val_xxx functions are changed to call cache_value function prior to returning cached value if value_cached is FALSE. The Arg_comparator::set_cmp_func function now calls cache_converted_constant to cache constants if they need a type conversion. The Item_cache::get_cache function is overloaded to allow setting of the cache type. The cache_converted_constant function is added to the Arg_comparator class. It checks whether a value can and should be cached and if so caches it. sql/item.cc: Bug#34384: Slow down on constant conversion. Function named cache_value() is added to the Item_cache class and derived classes. This function actually caches the value of the saved item. Item_cache_xxx::store functions now only store item to be cached and set value_cached flag to FALSE. Item_cache_xxx::val_xxx functions are changed to call cache_value function prior to returning cached value if value_cached is FALSE. The Item_cache::get_cache function is overloaded to allow setting of the cache type. sql/item.h: Bug#34384: Slow down on constant conversion. A flag named value_cached is added to the Item_cache class. It's set to TRUE when we need to start caching values when the store method is called. Function named cache_value() is added to the Item_cache class and derived classes. sql/item_cmpfunc.cc: Bug#34384: Slow down on constant conversion. A helper function cache_converted_constant is added to the Arg_comparator class. It checks whether a given item can and should be cached and caches it if so. The Arg_comparator::set_cmp_func function now calls cache_converted_constant to cache constants if they need a type conversion. sql/item_cmpfunc.h: Bug#34384: Slow down on constant conversion. The cache_converted_constant function is added to the Arg_comparator class. It checks whether a value can and should be cached and if so caches it. sql/item_subselect.cc: Bug#34384: Slow down on constant conversion. Force immediate caching of subselect result. sql/item_xmlfunc.cc: Bug#34384: Slow down on constant conversion. sql/sp_rcontext.cc: Bug#34384: Slow down on constant conversion. Force immediate caching of values of an SP CASE function.
2009-11-06 20:34:25 +01:00
row[i]->cache_value();
}
enum Item_result Item_singlerow_subselect::result_type() const
{
return engine->type();
}
/*
Don't rely on the result type to calculate field type.
Ask the engine instead.
*/
enum_field_types Item_singlerow_subselect::field_type() const
{
return engine->field_type();
}
void Item_singlerow_subselect::fix_length_and_dec()
{
if ((max_columns= engine->cols()) == 1)
{
engine->fix_length_and_dec(row= &value);
}
else
{
Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log Docs/mysqld_error.txt: Updated error messages Makefile.am: Added missing SSL library (Should be in source distribution) configure.in: Added missing SSL library include/sql_common.h: Move duplicated prototypes innobase/os/os0file.c: Added comment for line that could be removed innobase/srv/srv0srv.c: Added comment for line that could be removed innobase/srv/srv0start.c: Added comment for line that could be removed innobase/trx/trx0sys.c: Added cast to remove compiler warning isam/isamchk.c: Fixed compiler warning libmysql/conf_to_src.c: Include files in proper order myisam/mi_check.c: Removed else part that caused compiler warning myisam/mi_delete.c: Added cast myisam/mi_page.c: Added cast myisam/mi_preload.c: Added cast myisam/mi_write.c: Added cast myisam/myisampack.c: changed 'byte' to 'current_byte' to avoid compiler warnings mysql-test/mysql-test-run.sh: Removed start-from as test '<' is not portable and this can easily be done from command line mysys/hash.c: Added cast mysys/mf_wcomp.c: Removed not reached line mysys/my_append.c: Fixed include file order to get this more portable mysys/my_copy.c: Fixed include file order to get this more portable mysys/my_redel.c: Fixed include file order to get this more portable sql-common/client.c: More DBUG_PRINT sql-common/pack.c: Added casts becasue Fortre compiler apparently compares (ulonglong) < (longlong) as signed sql/ha_heap.cc: Changed variable names to not cause hidden variables sql/ha_innodb.cc: Changed variable names to not cause hidden variables sql/item.cc: Changed variable names to not cause hidden variables sql/item.h: Changed variable names to not cause hidden variables sql/item_cmpfunc.h: Changed variable names to not cause hidden variables sql/item_func.cc: Changed variable names to not cause hidden variables sql/item_subselect.cc: Changed variable names to not cause hidden variables sql/item_subselect.h: Changed variable names to not cause hidden variables sql/item_sum.cc: Changed variable names to not cause hidden variables sql/item_timefunc.cc: Changed variable names to not cause hidden variables sql/log.cc: Changed variable names to not cause hidden variables sql/protocol.cc: Changed variable names to not cause hidden variables sql/protocol.h: Changed variable names to not cause hidden variables Remove function not declared in protocol.cc sql/protocol_cursor.cc: Changed variable names to not cause hidden variables sql/set_var.cc: Added a lot of 'version_xxx' strings Changed 'bdb_version' to 'version_bdb' sql/sql_class.cc: Changed variable names to not cause hidden variables Add TMP_TABLE_PARAM::init() to allow one to initialize structure several times sql/sql_class.h: Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) sql/sql_derived.cc: Avoid copying TMP_TABLE_PARAM (Use class version instead) sql/sql_error.cc: More DBUG sql/sql_help.cc: Fixed compiler warning sql/sql_lex.cc: Changed variable names to not cause hidden variables sql/sql_list.h: Changed variable names to not cause hidden variables sql/sql_parse.cc: Changed variable names to not cause hidden variables sql/sql_select.cc: Changed variable names to not cause hidden variables Ensure that you don't send NULL to printf() for %s Fixed problem with printing sub selects to debug log sql/sql_select.h: Changed variable names to not cause hidden variables sql/sql_union.cc: Changed variable names to not cause hidden variables Don't use local copy of TMP_TABLE_PARAM (Caused core dump on Solaris) sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Remove warning strings/conf_to_src.c: Fixed include file order
2003-11-28 11:18:13 +01:00
if (!(row= (Item_cache**) sql_alloc(sizeof(Item_cache*)*max_columns)))
return;
engine->fix_length_and_dec(row);
value= *row;
}
unsigned_flag= value->unsigned_flag;
/*
If there are not tables in subquery then ability to have NULL value
depends on SELECT list (if single row subquery have tables then it
always can be NULL if there are not records fetched).
*/
if (engine->no_tables())
maybe_null= engine->may_be_null();
else
{
for (uint i= 0; i < max_columns; i++)
row[i]->maybe_null= TRUE;
}
}
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
/**
Add an expression cache for this subquery if it is needed
@param thd_arg Thread handle
@details
The function checks whether an expression cache is needed for this item
and if if so wraps the item into an item of the class
Item_exp_cache_wrapper with an appropriate expression cache set up there.
@note
used from Item::transform()
@return
new wrapper item if an expression cache is needed,
this item - otherwise
*/
Item* Item_singlerow_subselect::expr_cache_insert_transformer(uchar *thd_arg)
{
THD *thd= (THD*) thd_arg;
DBUG_ENTER("Item_singlerow_subselect::expr_cache_insert_transformer");
Fixed LP BUG#615760: Check on double cache assignment added into the transformation methods. Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/compare.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/group_by.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect4.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_cache.result: Added test suite for LP BUG#615760 mysql-test/r/subselect_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_opts.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_semijoin.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/suite/pbxt/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/t/subselect_cache.test: Cache parameters print added in EXPLAIN EXTENDED output. sql/item.cc: Item::set_expr_cache result fixed according to its description. Cache parameters print added in EXPLAIN EXTENDED output. sql/item.h: Cache parameters print added in EXPLAIN EXTENDED output. sql/item_cmpfunc.cc: Check on double cache assignment added into the transformation methods. sql/item_cmpfunc.h: Check on double cache assignment added into the transformation methods. sql/item_subselect.cc: Check on double cache assignment added into the transformation methods. sql/item_subselect.h: Check on double cache assignment added into the transformation methods. sql/sql_expression_cache.cc: Cache parameters print added. sql/sql_expression_cache.h: Cache parameters print added. sql/sql_select.cc: Removed unused method (now it is impossible to make double transformation with the cache). sql/sql_select.h: Removed unused method.
2010-09-06 14:34:24 +02:00
if (expr_cache)
DBUG_RETURN(expr_cache);
if (expr_cache_is_needed(thd) &&
Fixed LP BUG#800696. The problem was that optimizer removes some outer references (it they are constant for example) and the list of outer items built during prepare phase is not actual during execution phase when we need it as the cache parameters. First solution was use pointer on pointer on outer reference Item and initialize temporary table on demand. This solved most problem except case when optimiser also reduce Item which contains outer references ('OR' in this bug test suite). The solution is to build the list of outer reference items on execution phase (after optimization) on demand (just before temporary table creation) by walking Item tree and finding outer references among Item_ident (Item_field/Item_ref) and Item_sum items. Removed depends_on list (because it is not neede any mnore for the cache, in the place where it was used it replaced with upper_refs). Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references (or other expression parameters in future). mysql-test/r/subselect_cache.result: A new test added. mysql-test/r/subselect_scache.result: Changes in creating the cache and its paremeters order or adding arguments of aggregate function (which is a parameter also, but this has no influence on the result). mysql-test/t/subselect_cache.test: Added a new test. sql/item.cc: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. Item_cache_wrapper collect parameters befor initialization of its cache. sql/item.h: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/item_cmpfunc.cc: depends_on removed. Added processor (collect_outer_ref_processor) to collect outer references. sql/item_cmpfunc.h: Added processor (collect_outer_ref_processor) to collect outer references. sql/item_subselect.cc: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_subselect.h: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_sum.cc: Added processor (collect_outer_ref_processor) method to collect outer references. sql/item_sum.h: Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/opt_range.cc: depends_on removed. sql/sql_base.cc: depends_on removed. sql/sql_class.h: New iterator added. sql/sql_expression_cache.cc: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_expression_cache.h: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_lex.cc: depends_on removed. sql/sql_lex.h: depends_on removed. sql/sql_list.h: Added add_unique method to add only unique elements to the list. sql/sql_select.cc: Support of new Item list added. sql/sql_select.h: Support of new Item list added.
2011-07-19 22:19:10 +02:00
(expr_cache= set_expr_cache(thd)))
Fixed LP BUG#615760: Check on double cache assignment added into the transformation methods. Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/compare.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/group_by.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect4.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_cache.result: Added test suite for LP BUG#615760 mysql-test/r/subselect_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_opts.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_semijoin.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/suite/pbxt/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/t/subselect_cache.test: Cache parameters print added in EXPLAIN EXTENDED output. sql/item.cc: Item::set_expr_cache result fixed according to its description. Cache parameters print added in EXPLAIN EXTENDED output. sql/item.h: Cache parameters print added in EXPLAIN EXTENDED output. sql/item_cmpfunc.cc: Check on double cache assignment added into the transformation methods. sql/item_cmpfunc.h: Check on double cache assignment added into the transformation methods. sql/item_subselect.cc: Check on double cache assignment added into the transformation methods. sql/item_subselect.h: Check on double cache assignment added into the transformation methods. sql/sql_expression_cache.cc: Cache parameters print added. sql/sql_expression_cache.h: Cache parameters print added. sql/sql_select.cc: Removed unused method (now it is impossible to make double transformation with the cache). sql/sql_select.h: Removed unused method.
2010-09-06 14:34:24 +02:00
DBUG_RETURN(expr_cache);
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
DBUG_RETURN(this);
}
uint Item_singlerow_subselect::cols()
{
return engine->cols();
}
bool Item_singlerow_subselect::check_cols(uint c)
{
if (c != engine->cols())
{
fixed error names mysql-test/r/row.result: fixed error message as it was suggested by Peter Gulutzan mysql-test/r/subselect.result: fixed error message as it was suggested by Peter Gulutzan sql/share/czech/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/danish/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/dutch/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/english/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/estonian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/french/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/german/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/greek/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/hungarian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/italian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/japanese/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/korean/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/norwegian-ny/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/norwegian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/polish/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/portuguese/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/romanian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/russian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/serbian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/slovak/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/spanish/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/swedish/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan sql/share/ukrainian/errmsg.txt: fixed error message as it was suggested by Peter Gulutzan
2003-10-06 21:35:05 +02:00
my_error(ER_OPERAND_COLUMNS, MYF(0), c);
return 1;
}
return 0;
}
bool Item_singlerow_subselect::null_inside()
{
for (uint i= 0; i < max_columns ; i++)
{
if (row[i]->null_value)
return 1;
}
return 0;
}
void Item_singlerow_subselect::bring_value()
{
if (!exec() && assigned())
null_value= 0;
else
reset();
}
double Item_singlerow_subselect::val_real()
{
DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal
2004-03-18 14:14:36 +01:00
DBUG_ASSERT(fixed == 1);
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
if (forced_const)
return value->val_real();
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (!exec() && !value->null_value)
{
null_value= FALSE;
return value->val_real();
}
else
{
reset();
return 0;
}
}
longlong Item_singlerow_subselect::val_int()
{
DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal
2004-03-18 14:14:36 +01:00
DBUG_ASSERT(fixed == 1);
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
if (forced_const)
return value->val_int();
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (!exec() && !value->null_value)
{
null_value= FALSE;
return value->val_int();
}
else
{
reset();
return 0;
}
}
String *Item_singlerow_subselect::val_str(String *str)
{
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
DBUG_ASSERT(fixed == 1);
if (forced_const)
return value->val_str(str);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (!exec() && !value->null_value)
{
null_value= FALSE;
return value->val_str(str);
}
else
{
reset();
return 0;
}
}
my_decimal *Item_singlerow_subselect::val_decimal(my_decimal *decimal_value)
{
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
DBUG_ASSERT(fixed == 1);
if (forced_const)
return value->val_decimal(decimal_value);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (!exec() && !value->null_value)
{
null_value= FALSE;
return value->val_decimal(decimal_value);
}
else
{
reset();
return 0;
}
}
bool Item_singlerow_subselect::val_bool()
{
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
DBUG_ASSERT(fixed == 1);
if (forced_const)
return value->val_bool();
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (!exec() && !value->null_value)
{
null_value= FALSE;
return value->val_bool();
}
else
{
reset();
return 0;
}
}
bool Item_singlerow_subselect::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
DBUG_ASSERT(fixed == 1);
if (forced_const)
return value->get_date(ltime, fuzzydate);
if (!exec() && !value->null_value)
{
null_value= FALSE;
return value->get_date(ltime, fuzzydate);
}
else
{
reset();
return 0;
}
}
Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex):
Item_subselect()
{
DBUG_ENTER("Item_exists_subselect::Item_exists_subselect");
bool val_bool();
init(select_lex, new select_exists_subselect(this));
max_columns= UINT_MAX;
null_value= FALSE; //can't be NULL
maybe_null= 0; //can't be NULL
value= 0;
DBUG_VOID_RETURN;
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
void Item_exists_subselect::print(String *str, enum_query_type query_type)
{
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN("exists"));
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
Item_subselect::print(str, query_type);
}
bool Item_in_subselect::test_limit(st_select_lex_unit *unit_arg)
{
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
if (unit_arg->fake_select_lex &&
unit_arg->fake_select_lex->test_limit())
return(1);
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
SELECT_LEX *sl= unit_arg->first_select();
for (; sl; sl= sl->next_select())
{
if (sl->test_limit())
return(1);
}
return(0);
}
Item_in_subselect::Item_in_subselect(Item * left_exp,
st_select_lex *select_lex):
BUG#834534: Assertion `0' failed in replace_where_subcondition with semijoin subquery in HAVING - The problem was that the code that made the check whether the subquery is an AND-part of the WHERE clause didn't work correctly for nested subqueries. In particular, grand-child subquery in HAVING was treated as if it was in the WHERE, which eventually caused an assert when replace_where_subcondition looked for the subquery predicate in the WHERE and couldn't find it there. - The fix: Removed implementation of "thd_marker approach". thd->thd_marker was used to determine the location of subquery predicate: setup_conds() would set accordingly it when making the {where|on_expr}->fix_fields(...) call so that AND-parts of the WHERE/ON clauses can determine they are the AND-parts. Item_cond_or::fix_fields(), Item_func::fix_fields(), Item_subselect::fix_fields (this one was missed), and all other items-that-contain-items had to reset thd->thd_marker before calling fix_fields() for their children items, so that the children can see they are not AND-parts of WHERE/ON. - The "thd_marker approach" required that a lot of code in different locations maintains correct value of thd->thd_marker, so it was replaced with: - The new approach with mark_as_condition_AND_part does not keep context in thd->thd_marker. Instead, setup_conds() now calls {where|on_expr}->mark_as_condition_AND_part() and implementations of that function make sure that: - parts of AND-expressions get the mark_as_condition_AND_part() call - Item_in_subselect objects record that they are AND-parts of WHERE/ON
2011-08-29 17:57:41 +02:00
Item_exists_subselect(),
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
left_expr_cache(0), first_execution(TRUE), in_strategy(SUBS_NOT_TRANSFORMED),
optimizer(0), pushed_cond_guards(NULL), emb_on_expr_nest(NULL),
is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE),
is_flattenable_semijoin(FALSE),
is_registered_semijoin(FALSE),
2011-05-25 17:31:13 +02:00
upper_item(0)
{
DBUG_ENTER("Item_in_subselect::Item_in_subselect");
left_expr= left_exp;
func= &eq_creator;
init(select_lex, new select_exists_subselect(this));
max_columns= UINT_MAX;
maybe_null= 1;
abort_on_null= 0;
reset();
//if test_limit will fail then error will be reported to client
test_limit(select_lex->master_unit());
DBUG_VOID_RETURN;
}
int Item_in_subselect::get_identifier()
{
return engine->get_identifier();
}
Item_allany_subselect::Item_allany_subselect(Item * left_exp,
chooser_compare_func_creator fc,
st_select_lex *select_lex,
bool all_arg)
2006-07-22 14:18:28 +02:00
:Item_in_subselect(), func_creator(fc), all(all_arg)
{
DBUG_ENTER("Item_allany_subselect::Item_allany_subselect");
left_expr= left_exp;
func= func_creator(all_arg);
init(select_lex, new select_exists_subselect(this));
max_columns= 1;
abort_on_null= 0;
reset();
//if test_limit will fail then error will be reported to client
test_limit(select_lex->master_unit());
DBUG_VOID_RETURN;
}
/**
Initialize length and decimals for EXISTS and inherited (IN/ALL/ANY)
subqueries
*/
void Item_exists_subselect::init_length_and_dec()
{
decimals= 0;
max_length= 1;
max_columns= engine->cols();
}
void Item_exists_subselect::fix_length_and_dec()
{
DBUG_ENTER("Item_exists_subselect::fix_length_and_dec");
init_length_and_dec();
/*
We need only 1 row to determine existence (i.e. any EXISTS that is not
an IN always requires LIMIT 1)
*/
thd->change_item_tree(&unit->global_parameters->select_limit,
new Item_int((int32) 1));
DBUG_PRINT("info", ("Set limit to 1"));
DBUG_VOID_RETURN;
}
void Item_in_subselect::fix_length_and_dec()
{
DBUG_ENTER("Item_in_subselect::fix_length_and_dec");
init_length_and_dec();
/*
Unlike Item_exists_subselect, LIMIT 1 is set later for
Item_in_subselect, depending on the chosen strategy.
*/
DBUG_VOID_RETURN;
}
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
/**
Add an expression cache for this subquery if it is needed
@param thd_arg Thread handle
@details
The function checks whether an expression cache is needed for this item
and if if so wraps the item into an item of the class
Item_exp_cache_wrapper with an appropriate expression cache set up there.
@note
used from Item::transform()
@return
new wrapper item if an expression cache is needed,
this item - otherwise
*/
Item* Item_exists_subselect::expr_cache_insert_transformer(uchar *thd_arg)
{
THD *thd= (THD*) thd_arg;
DBUG_ENTER("Item_exists_subselect::expr_cache_insert_transformer");
Fixed LP BUG#615760: Check on double cache assignment added into the transformation methods. Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/compare.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/group_by.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect4.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_cache.result: Added test suite for LP BUG#615760 mysql-test/r/subselect_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_opts.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_semijoin.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/suite/pbxt/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/t/subselect_cache.test: Cache parameters print added in EXPLAIN EXTENDED output. sql/item.cc: Item::set_expr_cache result fixed according to its description. Cache parameters print added in EXPLAIN EXTENDED output. sql/item.h: Cache parameters print added in EXPLAIN EXTENDED output. sql/item_cmpfunc.cc: Check on double cache assignment added into the transformation methods. sql/item_cmpfunc.h: Check on double cache assignment added into the transformation methods. sql/item_subselect.cc: Check on double cache assignment added into the transformation methods. sql/item_subselect.h: Check on double cache assignment added into the transformation methods. sql/sql_expression_cache.cc: Cache parameters print added. sql/sql_expression_cache.h: Cache parameters print added. sql/sql_select.cc: Removed unused method (now it is impossible to make double transformation with the cache). sql/sql_select.h: Removed unused method.
2010-09-06 14:34:24 +02:00
if (expr_cache)
DBUG_RETURN(expr_cache);
if (substype() == EXISTS_SUBS && expr_cache_is_needed(thd) &&
Fixed LP BUG#800696. The problem was that optimizer removes some outer references (it they are constant for example) and the list of outer items built during prepare phase is not actual during execution phase when we need it as the cache parameters. First solution was use pointer on pointer on outer reference Item and initialize temporary table on demand. This solved most problem except case when optimiser also reduce Item which contains outer references ('OR' in this bug test suite). The solution is to build the list of outer reference items on execution phase (after optimization) on demand (just before temporary table creation) by walking Item tree and finding outer references among Item_ident (Item_field/Item_ref) and Item_sum items. Removed depends_on list (because it is not neede any mnore for the cache, in the place where it was used it replaced with upper_refs). Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references (or other expression parameters in future). mysql-test/r/subselect_cache.result: A new test added. mysql-test/r/subselect_scache.result: Changes in creating the cache and its paremeters order or adding arguments of aggregate function (which is a parameter also, but this has no influence on the result). mysql-test/t/subselect_cache.test: Added a new test. sql/item.cc: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. Item_cache_wrapper collect parameters befor initialization of its cache. sql/item.h: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/item_cmpfunc.cc: depends_on removed. Added processor (collect_outer_ref_processor) to collect outer references. sql/item_cmpfunc.h: Added processor (collect_outer_ref_processor) to collect outer references. sql/item_subselect.cc: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_subselect.h: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_sum.cc: Added processor (collect_outer_ref_processor) method to collect outer references. sql/item_sum.h: Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/opt_range.cc: depends_on removed. sql/sql_base.cc: depends_on removed. sql/sql_class.h: New iterator added. sql/sql_expression_cache.cc: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_expression_cache.h: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_lex.cc: depends_on removed. sql/sql_lex.h: depends_on removed. sql/sql_list.h: Added add_unique method to add only unique elements to the list. sql/sql_select.cc: Support of new Item list added. sql/sql_select.h: Support of new Item list added.
2011-07-19 22:19:10 +02:00
(expr_cache= set_expr_cache(thd)))
Fixed LP BUG#615760: Check on double cache assignment added into the transformation methods. Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/compare.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/group_by.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect3_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect4.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_cache.result: Added test suite for LP BUG#615760 mysql-test/r/subselect_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_mat.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_opts.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_no_semijoin.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/r/subselect_sj_jcl6.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/suite/pbxt/r/subselect.result: Cache parameters print added in EXPLAIN EXTENDED output. mysql-test/t/subselect_cache.test: Cache parameters print added in EXPLAIN EXTENDED output. sql/item.cc: Item::set_expr_cache result fixed according to its description. Cache parameters print added in EXPLAIN EXTENDED output. sql/item.h: Cache parameters print added in EXPLAIN EXTENDED output. sql/item_cmpfunc.cc: Check on double cache assignment added into the transformation methods. sql/item_cmpfunc.h: Check on double cache assignment added into the transformation methods. sql/item_subselect.cc: Check on double cache assignment added into the transformation methods. sql/item_subselect.h: Check on double cache assignment added into the transformation methods. sql/sql_expression_cache.cc: Cache parameters print added. sql/sql_expression_cache.h: Cache parameters print added. sql/sql_select.cc: Removed unused method (now it is impossible to make double transformation with the cache). sql/sql_select.h: Removed unused method.
2010-09-06 14:34:24 +02:00
DBUG_RETURN(expr_cache);
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
DBUG_RETURN(this);
}
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
void Item_exists_subselect::no_rows_in_result()
{
Fix bug lp:1008686 Analysis: The fix for bug lp:985667 implements the method Item_subselect::no_rows_in_result() for all main kinds of subqueries. The purpose of this method is to be called from return_zero_rows() and set Items to some default value in the case when a query returns no rows. Aggregates and subqueries require special treatment in this case. Every implementation of Item_subselect::no_rows_in_result() called Item_subselect::make_const() to set the subquery predicate to its default value irrespective of where the predicate was located in the query. Once the predicate was set to a constant it was never executed. At the same time, the JOIN object of the fake select for UNIONs (the one used for the final result of the UNION), was set after all subqueries in the union were executed. Since we set the subquery as constant, it was never executed, and the corresponding JOIN was never created. In order to decide whether the result of NOT IN is NULL or FALSE, Item_in_optimizer needs to check if the subquery result was empty or not. This is where we got the crash, because subselect_union_engine::no_rows() checks for unit->fake_select_lex->join->send_records, and the join object was NULL. Solution: If a subquery is in the HAVING clause it must be evaluated in order to know its result, so that we can properly filter the result records. Once subqueries in the HAVING clause are executed even in the case of no result rows, this specific crash will be solved, because the UNION will be executed, and its JOIN will be constructed. Therefore the fix for this crash is to narrow the fix for lp:985667, and to apply Item_subselect::no_rows_in_result() only when the subquery predicate is in the SELECT clause.
2012-06-15 10:33:24 +02:00
/*
Subquery predicates outside of the SELECT list must be evaluated in order
to possibly filter the special result row generated for implicit grouping
if the subquery is in the HAVING clause.
If the predicate is constant, we need its actual value in the only result
row for queries with implicit grouping.
*/
if (parsing_place != SELECT_LIST || const_item())
return;
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
value= 0;
null_value= 0;
make_const();
}
double Item_exists_subselect::val_real()
{
DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal
2004-03-18 14:14:36 +01:00
DBUG_ASSERT(fixed == 1);
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
if (!forced_const && exec())
{
reset();
return 0;
}
return (double) value;
}
longlong Item_exists_subselect::val_int()
{
DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal
2004-03-18 14:14:36 +01:00
DBUG_ASSERT(fixed == 1);
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
if (!forced_const && exec())
{
reset();
return 0;
}
return value;
}
/**
Return the result of EXISTS as a string value
Converts the true/false result into a string value.
Note that currently this cannot be NULL, so if the query exection fails
it will return 0.
@param decimal_value[out] buffer to hold the resulting string value
@retval Pointer to the converted string.
Can't be a NULL pointer, as currently
EXISTS cannot return NULL.
*/
String *Item_exists_subselect::val_str(String *str)
{
DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal
2004-03-18 14:14:36 +01:00
DBUG_ASSERT(fixed == 1);
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
if (!forced_const && exec())
reset();
str->set((ulonglong)value,&my_charset_bin);
return str;
}
/**
Return the result of EXISTS as a decimal value
Converts the true/false result into a decimal value.
Note that currently this cannot be NULL, so if the query exection fails
it will return 0.
@param decimal_value[out] Buffer to hold the resulting decimal value
@retval Pointer to the converted decimal.
Can't be a NULL pointer, as currently
EXISTS cannot return NULL.
*/
my_decimal *Item_exists_subselect::val_decimal(my_decimal *decimal_value)
{
DBUG_ASSERT(fixed == 1);
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
if (!forced_const && exec())
reset();
int2my_decimal(E_DEC_FATAL_ERROR, value, 0, decimal_value);
return decimal_value;
}
bool Item_exists_subselect::val_bool()
{
DBUG_ASSERT(fixed == 1);
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
if (!forced_const && exec())
{
reset();
return 0;
}
Eliminate warnings noticed by VC7. This includes fixing my_mmap() on Windows to call CreateFileMapping() with correct arguments, and propogating the introduction of query_id_t to everywhere query ids are passed around. (Bug #8826) libmysql/libmysql.c: Make implicit cast explicit myisam/mi_open.c: Make cast of value to smaller data size explicit myisam/mi_packrec.c: Cast file size (my_off_t) to size_t for mmap mysys/my_mmap.c: Fix Windows version of my_mmap() to use the right parameters for call to CreateFileMapping() sql/field.cc: Use temporary value of correct type sql/field.h: Use query_id_t for query_id value sql/ha_berkeley.cc: Fix flag check sql/ha_innodb.h: Use query_id_t for query_id value sql/handler.cc: Explain opt_using_transactions calculation, and add cast sql/handler.h: Fix forward declaration of COND sql/item.cc: Fix val_bool() tests of val_int() to avoid implicit cast sql/item_cmpfunc.cc: Fix typo in switch label sql/item_func.cc: Make implicit cast explicit sql/item_strfunc.cc: Now that query_id is a query_id_t, need to cast it to a ulong here sql/item_subselect.cc: Fix test of value sql/log.cc: Cast my_off_t used for file size to size_t for memory allocation Also cast my_off_t when using it to calculate the number of pages for TC log Cast total_ha_2pc to uchar when saving it sql/mysql_priv.h: Move up query_id definition so it can be used more widely sql/opt_range.cc: Add unused delete operator to prevent compiler warning sql/set_var.cc: Cast value for max_user_connections sql/sql_cache.cc: Remove unused label sql/sql_class.h: Fix query id values to be of type query_id_t sql/sql_db.cc: Move variable only used inside #ifdef within the #ifdef sql/sql_help.cc: Remove unused label sql/sql_insert.cc: Use query_id_t for query id values sql/sql_lex.h: Add unused delete operator to prevent compiler warning sql/sql_select.cc: Remove unused variable Make cast of value explicit sql/sql_select.h: Use query_id_t for query id values sql/sql_table.cc: Make comparison to function pointer explicit sql/sql_update.cc: Use query_id_t for query id values sql/table.h: Use query_id_t for query id values strings/ctype-simple.c: Add cast of long value to (char) in expression strings/ctype-ucs2.c: Add cast of long value to (char) in expression strings/ctype-utf8.c: Make cast to smaller size explicit
2005-03-19 01:12:25 +01:00
return value != 0;
}
double Item_in_subselect::val_real()
{
/*
As far as Item_in_subselect called only from Item_in_optimizer this
method should not be used
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal
2004-03-18 14:14:36 +01:00
DBUG_ASSERT(fixed == 1);
null_value= was_null= FALSE;
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (exec())
{
reset();
return 0;
}
if (was_null && !value)
null_value= TRUE;
return (double) value;
}
longlong Item_in_subselect::val_int()
{
/*
As far as Item_in_subselect called only from Item_in_optimizer this
method should not be used
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal
2004-03-18 14:14:36 +01:00
DBUG_ASSERT(fixed == 1);
null_value= was_null= FALSE;
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (exec())
{
reset();
return 0;
}
if (was_null && !value)
null_value= TRUE;
return value;
}
String *Item_in_subselect::val_str(String *str)
{
/*
As far as Item_in_subselect called only from Item_in_optimizer this
method should not be used
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal
2004-03-18 14:14:36 +01:00
DBUG_ASSERT(fixed == 1);
null_value= was_null= FALSE;
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (exec())
{
reset();
return 0;
}
if (was_null && !value)
{
null_value= TRUE;
return 0;
}
str->set((ulonglong)value, &my_charset_bin);
return str;
}
bool Item_in_subselect::val_bool()
{
DBUG_ASSERT(fixed == 1);
if (forced_const)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
return value;
null_value= was_null= FALSE;
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (exec())
{
reset();
return 0;
}
if (was_null && !value)
null_value= TRUE;
return value;
}
my_decimal *Item_in_subselect::val_decimal(my_decimal *decimal_value)
{
/*
As far as Item_in_subselect called only from Item_in_optimizer this
method should not be used
*/
DBUG_ASSERT(0);
null_value= was_null= FALSE;
DBUG_ASSERT(fixed == 1);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (exec())
{
reset();
return 0;
}
if (was_null && !value)
null_value= TRUE;
int2my_decimal(E_DEC_FATAL_ERROR, value, 0, decimal_value);
return decimal_value;
}
/**
Prepare a single-column IN/ALL/ANY subselect for rewriting.
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
@param join Join object of the subquery (i.e. 'child' join).
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
@details
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
Prepare a single-column subquery to be rewritten. Given the subquery.
If the subquery has no tables it will be turned to an expression between
left part and SELECT list.
In other cases the subquery will be wrapped with Item_in_optimizer which
allow later to turn it to EXISTS or MAX/MIN.
@retval false The subquery was transformed
@retval true Error
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
*/
bool
Item_in_subselect::single_value_transformer(JOIN *join)
{
SELECT_LEX *select_lex= join->select_lex;
DBUG_ENTER("Item_in_subselect::single_value_transformer");
Merge with 4.1 (Includes merge of arena code in 4.1 and 5.0) BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged client/mysql.cc: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/client_settings.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/examples/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged myisam/sort.c: Auto merged mysql-test/r/connect.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/func_in.result: Auto merged mysql-test/r/func_like.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/having.result: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/join.result: Auto merged mysql-test/r/key.result: Auto merged mysql-test/r/lowercase_table.result: Auto merged mysql-test/r/ndb_autodiscover.result: Auto merged mysql-test/r/null.result: Auto merged mysql-test/r/olap.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/rename.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/null.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/rpl_charset.test: Auto merged mysql-test/t/rpl_heap.test: Auto merged mysql-test/t/rpl_relayrotate.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/variables.test: Auto merged netware/mysql_test_run.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged scripts/mysql_install_db.sh: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_create.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_sum.cc: Auto merged sql/protocol.cc: Auto merged sql/records.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_list.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_string.h: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged client/mysqlbinlog.cc: Merge with 4.1 configure.in: Merge with 4.1 include/mysqld_error.h: Add new error message (1) from 4.1 mysql-test/mysql-test-run.sh: Merge with 4.1 mysql-test/r/func_gconcat.result: Merge with 4.1 mysql-test/r/func_if.result: Merge with 4.1 mysql-test/r/grant.result: Merge with 4.1 mysql-test/r/join_outer.result: Merge with 4.1 mysql-test/r/rpl_charset.result: Merge with 4.1 (This has to be fixed before pushing) mysql-test/r/system_mysql_db.result: Merge with 4.1. Added collation to new privileges mysql-test/t/grant.test: Merge with 4.1 mysql-test/t/grant_cache.test: Merge with 4.1 mysql-test/t/show_check.test: Merge with 4.1 sql/Makefile.am: Merge with 4.1 sql/item.cc: Merge with 4.1 sql/item_cmpfunc.cc: Merge with 4.1 (arena code) sql/item_subselect.cc: Merge with 4.1 sql/item_subselect.h: Merge with 4.1 sql/item_sum.cc: Merge with 4.1 sql/item_sum.h: Merge with 4.1 sql/log.cc: Merge with 4.1 (Remove code that is not relevant for 5.0) sql/mysqld.cc: Merge with 4.1 sql/opt_range.cc: Merge with 4.1 sql/share/czech/errmsg.txt: Merge with 4.1 sql/share/danish/errmsg.txt: Merge with 4.1 sql/share/dutch/errmsg.txt: Merge with 4.1 sql/share/english/errmsg.txt: Merge with 4.1 sql/share/estonian/errmsg.txt: Merge with 4.1 sql/share/french/errmsg.txt: Merge with 4.1 sql/share/german/errmsg.txt: Merge with 4.1 sql/share/greek/errmsg.txt: Merge with 4.1 sql/share/hungarian/errmsg.txt: Merge with 4.1 sql/share/italian/errmsg.txt: Merge with 4.1 sql/share/japanese/errmsg.txt: Merge with 4.1 sql/share/korean/errmsg.txt: Merge with 4.1 sql/share/norwegian-ny/errmsg.txt: Merge with 4.1 sql/share/norwegian/errmsg.txt: Merge with 4.1 sql/share/polish/errmsg.txt: Merge with 4.1 sql/share/portuguese/errmsg.txt: Merge with 4.1 sql/share/romanian/errmsg.txt: Merge with 4.1 sql/share/russian/errmsg.txt: Merge with 4.1 sql/share/serbian/errmsg.txt: Merge with 4.1 sql/share/slovak/errmsg.txt: Merge with 4.1 sql/share/spanish/errmsg.txt: Merge with 4.1 sql/share/swedish/errmsg.txt: Merge with 4.1 sql/share/ukrainian/errmsg.txt: Merge with 4.1 sql/sql_base.cc: Merge with 4.1 sql/sql_class.cc: Merge with 4.1 Use arena code from 4.1 sql/sql_class.h: Merge with 4.1 Use arena code from 4.1 sql/sql_derived.cc: Merge with 4.1 sql/sql_lex.cc: Merge with 4.1 sql/sql_lex.h: Merge with 4.1 sql/sql_parse.cc: Merge with 4.1 sql/sql_prepare.cc: Merge with 4.1 sql/sql_select.cc: Merge with 4.1 sql/sql_table.cc: Merge with 4.1 sql/sql_union.cc: Merge with 4.1 sql/sql_yacc.yy: Merge with 4.1 sql/tztime.cc: Merge with 4.1 tests/client_test.c: Merge with 4.1
2004-09-06 14:14:10 +02:00
/*
Check that the right part of the subselect contains no more than one
column. E.g. in SELECT 1 IN (SELECT * ..) the right part is (SELECT * ...)
*/
// psergey: duplicated_subselect_card_check
if (select_lex->item_list.elements > 1)
{
my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
DBUG_RETURN(true);
}
Item* join_having= join->having ? join->having : join->tmp_having;
if (!(join_having || select_lex->with_sum_func ||
select_lex->group_list.elements) &&
select_lex->table_list.elements == 0 &&
!select_lex->master_unit()->is_union())
{
Item *where_item= (Item*) select_lex->item_list.head();
/*
it is single select without tables => possible optimization
remove the dependence mark since the item is moved to upper
select and is not outer anymore.
*/
where_item->walk(&Item::remove_dependence_processor, 0,
(uchar *) select_lex->outer_select());
substitution= func->create(left_expr, where_item);
have_to_be_excluded= 1;
if (thd->lex->describe)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number);
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_SELECT_REDUCED, warn_buff);
}
DBUG_RETURN(false);
}
/*
Wrap the current IN predicate in an Item_in_optimizer. The actual
substitution in the Item tree takes place in Item_subselect::fix_fields.
*/
if (!substitution)
{
/* We're invoked for the 1st (or the only) SELECT in the subquery UNION */
substitution= optimizer;
Fixed compiler warnings in a lot of files Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined client/get_password.c: Fixed compiler warning cmd-line-utils/readline/bind.c: Fixed compiler warning cmd-line-utils/readline/chardefs.h: Fixed compiler warning by adding marco to be used when largest_char is 255 cmd-line-utils/readline/display.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/histexpand.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/history.c: Fixed compiler warnings by adding cast cmd-line-utils/readline/text.c: Fixed compiler warnings by removing not accessed variables and adding casts dbug/dbug.c: Fixed compiler warnings by changing types include/mysql_com.h: Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value libmysql/libmysql.c: Fixed compiler warning mysql-test/t/query_cache_debug.test: Mark test as BIG as it uses a lot of memory mysys/mf_iocache2.c: Fixed compiler warnings by adding cast sql/event_data_objects.cc: Fixed compiler warnings by removing not used code sql/events.cc: Fixed compiler warnings by removing not used code sql/field.cc: Fixed compiler warnings by adding cast and removed not accessed variables sql/ha_partition.cc: Fixed compiler warnings by removing not used code sql/item.cc: Fixed compiler warnings by removing not accessed variables Use IMPOSSIBLE_RESULT instead of (Item_result)-1 sql/item_cmpfunc.cc: Fixed compiler warnings by removing not accessed variables sql/item_func.cc: Fixed compiler warnings by removing not used code and not accessed variables Added IMPOSSIBLE_RESULT sql/item_subselect.cc: Fixed compiler warnings by removing not accessed variables sql/item_xmlfunc.cc: Fixed forgotten setting of xpath->error sql/log.cc: Fixed compiler warnings by removing not accessed variables sql/log_event.cc: Added IMPOSSIBLE_RESULT into switch Fixed wrong usage of DBUG_ASSERT(1) Removed always true DBUG_ASSERT() sql/mysqld.cc: Fixed compiler warnings by adding casts for ULONG_MAX sql/opt_sum.cc: Fixed compiler warnings by removing not used code Removed wrong DBUG_ASSERT() sql/partition_info.cc: Fixed compiler warnings by removing not accessed variables sql/rpl_injector.h: Removed always true part from DBUG_ASSERT() to remove compiler warning sql/spatial.cc: Fixed compiler warnings by removing not accessed variables sql/sql_acl.cc: Fixed compiler warnings by removing not accessed variables sql/sql_base.cc: Fixed compiler warnings by removing not accessed variables sql/sql_cache.cc: Fixed compiler warnings by removing not accessed variables sql/sql_class.cc: Fixed compiler warnings by: - Removing always true part from DBUG_ASSERT() - Removing not used code - Added IMPOSSIBLE_RESULT into switch sql/sql_load.cc: Fixed compiler warnings by removing not accessed variables sql/sql_parse.cc: Fixed compiler warnings by: - Removing not accessed variables - Removing always true part from DBUG_ASSERT() - Removing not used code sql/sql_plugin.cc: Added comment sql/sql_prepare.cc: Fixed compiler warnings by removing not accessed variables sql/sql_show.cc: Fixed compiler warnings by using correct cast sql/sql_table.cc: Fixed compiler warnings by removing not used code and removing not accessed variables sql/table.cc: Fixed compiler warnings by removing not accessed variables sql/time.cc: Fixed wrong DBUG_ASSERT(1) storage/maria/unittest/Makefile.am: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_consist.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_single.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined tests/mysql_client_test.c: Fixed compiler warnings by removing not accessed variables and changing types
2008-02-13 20:27:12 +01:00
SELECT_LEX *current= thd->lex->current_select;
(SCRUM) It looks like samll revolution in SELECT_LEX tree, but it was only natural way to solve problem with name resolution of external fields inside subselect which belongs to global order of union also it have following advantages: - removed mess with current_select type conversion - type checking/converting - a lot of virtual methods - fake select for union execution allocated only once (it was allocated for every subselect with union executing) changes: fixed bug with outer fields name resolution of subqueries which belong to global ORDER BY clause remuved select_lex() function, now thd->lex.current_select always have type SELECT_LEX new SELECT_LEX (fake_select_lex) will be allocated in case of UNION for using in UNION processing fake_select_lex allocated for union hold global ORDER BY & LIMIT clauses and have linkage equal to GLOBAL_OPTIONS_TYPE new description of SELECT_LEX tree (SCRUM) sql/item.cc: global parameters moved to fake_select_lex sql/item_subselect.cc: global parameters moved to fake_select_lex sql/item_sum.cc: no need type checking & converion now sql/sql_delete.cc: no need type checking & converion now sql/sql_derived.cc: global parameters moved to fake_select_lex sql/sql_lex.cc: not used fields/mrthods moved from st_select_lex_node to st_select_lex global parameters moved to fake_select_lex sql/sql_lex.h: comments about new tree of select_lex s not used fields/mrthods moved from st_select_lex_node to st_select_lex global parameters moved to fake_select_lex sql/sql_parse.cc: global parameters moved to fake_select_lex allocation of fake_select_lex on demand sql/sql_select.cc: now fake_select_lex marked as GLOBAL_OPTIONS_TYPE sql/sql_union.cc: global parameters moved to fake_select_lex sql/sql_yacc.yy: global parameters moved to fake_select_lex
2003-07-03 01:30:52 +02:00
Fixed compiler warnings in a lot of files Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined client/get_password.c: Fixed compiler warning cmd-line-utils/readline/bind.c: Fixed compiler warning cmd-line-utils/readline/chardefs.h: Fixed compiler warning by adding marco to be used when largest_char is 255 cmd-line-utils/readline/display.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/histexpand.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/history.c: Fixed compiler warnings by adding cast cmd-line-utils/readline/text.c: Fixed compiler warnings by removing not accessed variables and adding casts dbug/dbug.c: Fixed compiler warnings by changing types include/mysql_com.h: Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value libmysql/libmysql.c: Fixed compiler warning mysql-test/t/query_cache_debug.test: Mark test as BIG as it uses a lot of memory mysys/mf_iocache2.c: Fixed compiler warnings by adding cast sql/event_data_objects.cc: Fixed compiler warnings by removing not used code sql/events.cc: Fixed compiler warnings by removing not used code sql/field.cc: Fixed compiler warnings by adding cast and removed not accessed variables sql/ha_partition.cc: Fixed compiler warnings by removing not used code sql/item.cc: Fixed compiler warnings by removing not accessed variables Use IMPOSSIBLE_RESULT instead of (Item_result)-1 sql/item_cmpfunc.cc: Fixed compiler warnings by removing not accessed variables sql/item_func.cc: Fixed compiler warnings by removing not used code and not accessed variables Added IMPOSSIBLE_RESULT sql/item_subselect.cc: Fixed compiler warnings by removing not accessed variables sql/item_xmlfunc.cc: Fixed forgotten setting of xpath->error sql/log.cc: Fixed compiler warnings by removing not accessed variables sql/log_event.cc: Added IMPOSSIBLE_RESULT into switch Fixed wrong usage of DBUG_ASSERT(1) Removed always true DBUG_ASSERT() sql/mysqld.cc: Fixed compiler warnings by adding casts for ULONG_MAX sql/opt_sum.cc: Fixed compiler warnings by removing not used code Removed wrong DBUG_ASSERT() sql/partition_info.cc: Fixed compiler warnings by removing not accessed variables sql/rpl_injector.h: Removed always true part from DBUG_ASSERT() to remove compiler warning sql/spatial.cc: Fixed compiler warnings by removing not accessed variables sql/sql_acl.cc: Fixed compiler warnings by removing not accessed variables sql/sql_base.cc: Fixed compiler warnings by removing not accessed variables sql/sql_cache.cc: Fixed compiler warnings by removing not accessed variables sql/sql_class.cc: Fixed compiler warnings by: - Removing always true part from DBUG_ASSERT() - Removing not used code - Added IMPOSSIBLE_RESULT into switch sql/sql_load.cc: Fixed compiler warnings by removing not accessed variables sql/sql_parse.cc: Fixed compiler warnings by: - Removing not accessed variables - Removing always true part from DBUG_ASSERT() - Removing not used code sql/sql_plugin.cc: Added comment sql/sql_prepare.cc: Fixed compiler warnings by removing not accessed variables sql/sql_show.cc: Fixed compiler warnings by using correct cast sql/sql_table.cc: Fixed compiler warnings by removing not used code and removing not accessed variables sql/table.cc: Fixed compiler warnings by removing not accessed variables sql/time.cc: Fixed wrong DBUG_ASSERT(1) storage/maria/unittest/Makefile.am: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_consist.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_single.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined tests/mysql_client_test.c: Fixed compiler warnings by removing not accessed variables and changing types
2008-02-13 20:27:12 +01:00
thd->lex->current_select= current->return_after_parsing();
//optimizer never use Item **ref => we can pass 0 as parameter
Name resolution context added (BUG#6443) include/my_bitmap.h: new bitmap operation mysql-test/r/view.result: added warnings Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysql-test/t/view.test: Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysys/my_bitmap.c: new bitmap operation sql/field.h: index of field in table added sql/item.cc: Name resolution context added table list removed from fix_fields() arguments sql/item.h: Name resolution context added table list removed from fix_fields() arguments sql/item_cmpfunc.cc: table list removed from fix_fields() arguments sql/item_cmpfunc.h: table list removed from fix_fields() arguments sql/item_func.cc: table list removed from fix_fields() arguments sql/item_func.h: table list removed from fix_fields() arguments sql/item_row.cc: table list removed from fix_fields() arguments sql/item_row.h: table list removed from fix_fields() arguments sql/item_strfunc.cc: fixed server crash on NULL argument sql/item_strfunc.h: table list removed from fix_fields() arguments sql/item_subselect.cc: table list removed from fix_fields() arguments sql/item_subselect.h: table list removed from fix_fields() arguments sql/item_sum.cc: table list removed from fix_fields() arguments sql/item_sum.h: table list removed from fix_fields() arguments sql/item_timefunc.cc: table list removed from fix_fields() arguments sql/item_timefunc.h: table list removed from fix_fields() arguments sql/item_uniq.h: table list removed from fix_fields() arguments sql/log_event.cc: Name resolution context added sql/log_event.h: Name resolution context added sql/mysql_priv.h: Name resolution context added sql/set_var.cc: table list removed from fix_fields() arguments sql/share/errmsg.txt: new error message sql/sp.cc: Name resolution context added sql/sp_head.cc: table list removed from fix_fields() arguments sql/sp_head.h: Name resolution context added sql/sql_base.cc: table list removed from fix_fields() arguments Name resolution context added sql/sql_class.cc: renamed variable sql/sql_delete.cc: Name resolution context added sql/sql_derived.cc: Name resolution context added sql/sql_do.cc: table list removed from fix_fields() arguments sql/sql_handler.cc: Name resolution context added sql/sql_help.cc: Name resolution context added sql/sql_insert.cc: Name resolution context added table list removed from fix_fields() arguments sql/sql_lex.cc: Name resolution context added sql/sql_lex.h: removed resolve mode (information stored into name resolution context) sql/sql_load.cc: table list removed from fix_fields() arguments sql/sql_olap.cc: Name resolution context added sql/sql_parse.cc: Name resolution context added sql/sql_prepare.cc: table list removed from fix_fields() arguments sql/sql_select.cc: table list removed from fix_fields() arguments sql/sql_show.cc: Name resolution context added sql/sql_trigger.cc: table list removed from fix_fields() arguments sql/sql_udf.h: table list removed from fix_fields() arguments sql/sql_union.cc: Name resolution context added sql/sql_update.cc: Name resolution context added sql/sql_view.cc: Name resolution context added sql/sql_view.h: table list removed from fix_fields() arguments sql/sql_yacc.yy: Name resolution context added sql/table.cc: Name resolution context added merged view processing moved sql/table.h: merged view processing moved
2005-07-01 06:05:42 +02:00
if (!optimizer || optimizer->fix_left(thd, 0))
2002-12-23 17:25:25 +01:00
{
thd->lex->current_select= current;
DBUG_RETURN(true);
2002-12-23 17:25:25 +01:00
}
thd->lex->current_select= current;
2002-12-23 17:25:25 +01:00
/* We will refer to upper level cache array => we have to save it for SP */
optimizer->keep_top_level_cache();
/*
As far as Item_ref_in_optimizer do not substitute itself on fix_fields
we can use same item for all selects.
*/
Name resolution context added (BUG#6443) include/my_bitmap.h: new bitmap operation mysql-test/r/view.result: added warnings Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysql-test/t/view.test: Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysys/my_bitmap.c: new bitmap operation sql/field.h: index of field in table added sql/item.cc: Name resolution context added table list removed from fix_fields() arguments sql/item.h: Name resolution context added table list removed from fix_fields() arguments sql/item_cmpfunc.cc: table list removed from fix_fields() arguments sql/item_cmpfunc.h: table list removed from fix_fields() arguments sql/item_func.cc: table list removed from fix_fields() arguments sql/item_func.h: table list removed from fix_fields() arguments sql/item_row.cc: table list removed from fix_fields() arguments sql/item_row.h: table list removed from fix_fields() arguments sql/item_strfunc.cc: fixed server crash on NULL argument sql/item_strfunc.h: table list removed from fix_fields() arguments sql/item_subselect.cc: table list removed from fix_fields() arguments sql/item_subselect.h: table list removed from fix_fields() arguments sql/item_sum.cc: table list removed from fix_fields() arguments sql/item_sum.h: table list removed from fix_fields() arguments sql/item_timefunc.cc: table list removed from fix_fields() arguments sql/item_timefunc.h: table list removed from fix_fields() arguments sql/item_uniq.h: table list removed from fix_fields() arguments sql/log_event.cc: Name resolution context added sql/log_event.h: Name resolution context added sql/mysql_priv.h: Name resolution context added sql/set_var.cc: table list removed from fix_fields() arguments sql/share/errmsg.txt: new error message sql/sp.cc: Name resolution context added sql/sp_head.cc: table list removed from fix_fields() arguments sql/sp_head.h: Name resolution context added sql/sql_base.cc: table list removed from fix_fields() arguments Name resolution context added sql/sql_class.cc: renamed variable sql/sql_delete.cc: Name resolution context added sql/sql_derived.cc: Name resolution context added sql/sql_do.cc: table list removed from fix_fields() arguments sql/sql_handler.cc: Name resolution context added sql/sql_help.cc: Name resolution context added sql/sql_insert.cc: Name resolution context added table list removed from fix_fields() arguments sql/sql_lex.cc: Name resolution context added sql/sql_lex.h: removed resolve mode (information stored into name resolution context) sql/sql_load.cc: table list removed from fix_fields() arguments sql/sql_olap.cc: Name resolution context added sql/sql_parse.cc: Name resolution context added sql/sql_prepare.cc: table list removed from fix_fields() arguments sql/sql_select.cc: table list removed from fix_fields() arguments sql/sql_show.cc: Name resolution context added sql/sql_trigger.cc: table list removed from fix_fields() arguments sql/sql_udf.h: table list removed from fix_fields() arguments sql/sql_union.cc: Name resolution context added sql/sql_update.cc: Name resolution context added sql/sql_view.cc: Name resolution context added sql/sql_view.h: table list removed from fix_fields() arguments sql/sql_yacc.yy: Name resolution context added sql/table.cc: Name resolution context added merged view processing moved sql/table.h: merged view processing moved
2005-07-01 06:05:42 +02:00
expr= new Item_direct_ref(&select_lex->context,
(Item**)optimizer->get_cache(),
(char *)"<no matter>",
(char *)in_left_expr_name);
}
DBUG_RETURN(false);
}
/**
Apply transformation max/min transwormation to ALL/ANY subquery if it is
possible.
@param join Join object of the subquery (i.e. 'child' join).
@details
If this is an ALL/ANY single-value subselect, try to rewrite it with
a MIN/MAX subselect. We can do that if a possible NULL result of the
subselect can be ignored.
E.g. SELECT * FROM t1 WHERE b > ANY (SELECT a FROM t2) can be rewritten
with SELECT * FROM t1 WHERE b > (SELECT MAX(a) FROM t2).
We can't check that this optimization is safe if it's not a top-level
item of the WHERE clause (e.g. because the WHERE clause can contain IS
NULL/IS NOT NULL functions). If so, we rewrite ALL/ANY with NOT EXISTS
later in this method.
@retval false The subquery was transformed
@retval true Error
*/
bool Item_allany_subselect::transform_into_max_min(JOIN *join)
{
DBUG_ENTER("Item_allany_subselect::transform_into_max_min");
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
if (!test_strategy(SUBS_MAXMIN_INJECTED | SUBS_MAXMIN_ENGINE))
DBUG_RETURN(false);
Item **place= optimizer->arguments() + 1;
THD *thd= join->thd;
SELECT_LEX *select_lex= join->select_lex;
Item *subs;
/*
*/
DBUG_ASSERT(!substitution);
2011-09-02 14:10:10 +02:00
/*
Check if optimization with aggregate min/max possible
1 There is no aggregate in the subquery
2 It is not UNION
3 There is tables
4 It is not ALL subquery with possible NULLs in the SELECT list
*/
if (!select_lex->group_list.elements && /*1*/
!select_lex->having && /*1*/
!select_lex->with_sum_func && /*1*/
!(select_lex->next_select()) && /*2*/
select_lex->table_list.elements && /*3*/
(!select_lex->ref_pointer_array[0]->maybe_null || /*4*/
substype() != Item_subselect::ALL_SUBS)) /*4*/
{
Item_sum_hybrid *item;
nesting_map save_allow_sum_func;
if (func->l_op())
{
/*
(ALL && (> || =>)) || (ANY && (< || =<))
for ALL condition is inverted
*/
item= new Item_sum_max(*select_lex->ref_pointer_array);
}
else
{
/*
(ALL && (< || =<)) || (ANY && (> || =>))
for ALL condition is inverted
*/
item= new Item_sum_min(*select_lex->ref_pointer_array);
}
if (upper_item)
upper_item->set_sum_test(item);
thd->change_item_tree(select_lex->ref_pointer_array, item);
{
List_iterator<Item> it(select_lex->item_list);
it++;
thd->change_item_tree(it.ref(), item);
}
DBUG_EXECUTE("where",
print_where(item, "rewrite with MIN/MAX", QT_ORDINARY););
save_allow_sum_func= thd->lex->allow_sum_func;
thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
/*
Item_sum_(max|min) can't substitute other item => we can use 0 as
reference, also Item_sum_(max|min) can't be fixed after creation, so
we do not check item->fixed
*/
if (item->fix_fields(thd, 0))
DBUG_RETURN(true);
thd->lex->allow_sum_func= save_allow_sum_func;
/* we added aggregate function => we have to change statistic */
count_field_types(select_lex, &join->tmp_table_param, join->all_fields,
0);
if (join->prepare_stage2())
DBUG_RETURN(true);
subs= new Item_singlerow_subselect(select_lex);
/*
Remove other strategies if any (we already changed the query and
can't apply other strategy).
*/
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
set_strategy(SUBS_MAXMIN_INJECTED);
}
else
{
Item_maxmin_subselect *item;
subs= item= new Item_maxmin_subselect(thd, this, select_lex, func->l_op());
if (upper_item)
upper_item->set_sub_test(item);
/*
Remove other strategies if any (we already changed the query and
can't apply other strategy).
*/
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
set_strategy(SUBS_MAXMIN_ENGINE);
}
/*
The swap is needed for expressions of type 'f1 < ALL ( SELECT ....)'
where we want to evaluate the sub query even if f1 would be null.
*/
subs= func->create_swap(*(optimizer->get_cache()), subs);
thd->change_item_tree(place, subs);
if (subs->fix_fields(thd, &subs))
DBUG_RETURN(true);
DBUG_ASSERT(subs == (*place)); // There was no substitutions
select_lex->master_unit()->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
select_lex->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
DBUG_RETURN(false);
}
bool Item_in_subselect::fix_having(Item *having, SELECT_LEX *select_lex)
{
bool fix_res= 0;
if (!having->fixed)
{
select_lex->having_fix_field= 1;
fix_res= having->fix_fields(thd, 0);
select_lex->having_fix_field= 0;
}
return fix_res;
}
bool Item_allany_subselect::is_maxmin_applicable(JOIN *join)
{
/*
Check if max/min optimization applicable: It is top item of
WHERE condition.
*/
return (abort_on_null || (upper_item && upper_item->is_top_level_item())) &&
!join->select_lex->master_unit()->uncacheable && !func->eqne_op();
}
/**
Create the predicates needed to transform a single-column IN/ALL/ANY
subselect into a correlated EXISTS via predicate injection.
@param join[in] Join object of the subquery (i.e. 'child' join).
@param where_item[out] the in-to-exists addition to the where clause
@param having_item[out] the in-to-exists addition to the having clause
@details
The correlated predicates are created as follows:
- If the subquery has aggregates, GROUP BY, or HAVING, convert to
SELECT ie FROM ... HAVING subq_having AND
trigcond(oe $cmp$ ref_or_null_helper<ie>)
the addition is wrapped into trigger only when we want to distinguish
between NULL and FALSE results.
- Otherwise (no aggregates/GROUP BY/HAVING) convert it to one of the
following:
= If we don't need to distinguish between NULL and FALSE subquery:
SELECT ie FROM ... WHERE subq_where AND (oe $cmp$ ie)
= If we need to distinguish between those:
SELECT ie FROM ...
WHERE subq_where AND trigcond((oe $cmp$ ie) OR (ie IS NULL))
HAVING trigcond(<is_not_null_test>(ie))
@retval false If the new conditions were created successfully
@retval true Error
*/
bool
Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
Item **where_item,
Item **having_item)
{
SELECT_LEX *select_lex= join->select_lex;
/*
The non-transformed HAVING clause of 'join' may be stored in two ways
during JOIN::optimize: this->tmp_having= this->having; this->having= 0;
*/
Item* join_having= join->having ? join->having : join->tmp_having;
DBUG_ENTER("Item_in_subselect::create_single_in_to_exists_cond");
*where_item= NULL;
*having_item= NULL;
if (join_having || select_lex->with_sum_func ||
select_lex->group_list.elements)
{
Merge with 4.1 (Includes merge of arena code in 4.1 and 5.0) BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged client/mysql.cc: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/client_settings.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/examples/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged myisam/sort.c: Auto merged mysql-test/r/connect.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/func_in.result: Auto merged mysql-test/r/func_like.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/having.result: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/join.result: Auto merged mysql-test/r/key.result: Auto merged mysql-test/r/lowercase_table.result: Auto merged mysql-test/r/ndb_autodiscover.result: Auto merged mysql-test/r/null.result: Auto merged mysql-test/r/olap.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/rename.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/null.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/rpl_charset.test: Auto merged mysql-test/t/rpl_heap.test: Auto merged mysql-test/t/rpl_relayrotate.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/variables.test: Auto merged netware/mysql_test_run.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged scripts/mysql_install_db.sh: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_create.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_sum.cc: Auto merged sql/protocol.cc: Auto merged sql/records.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_list.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_string.h: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged client/mysqlbinlog.cc: Merge with 4.1 configure.in: Merge with 4.1 include/mysqld_error.h: Add new error message (1) from 4.1 mysql-test/mysql-test-run.sh: Merge with 4.1 mysql-test/r/func_gconcat.result: Merge with 4.1 mysql-test/r/func_if.result: Merge with 4.1 mysql-test/r/grant.result: Merge with 4.1 mysql-test/r/join_outer.result: Merge with 4.1 mysql-test/r/rpl_charset.result: Merge with 4.1 (This has to be fixed before pushing) mysql-test/r/system_mysql_db.result: Merge with 4.1. Added collation to new privileges mysql-test/t/grant.test: Merge with 4.1 mysql-test/t/grant_cache.test: Merge with 4.1 mysql-test/t/show_check.test: Merge with 4.1 sql/Makefile.am: Merge with 4.1 sql/item.cc: Merge with 4.1 sql/item_cmpfunc.cc: Merge with 4.1 (arena code) sql/item_subselect.cc: Merge with 4.1 sql/item_subselect.h: Merge with 4.1 sql/item_sum.cc: Merge with 4.1 sql/item_sum.h: Merge with 4.1 sql/log.cc: Merge with 4.1 (Remove code that is not relevant for 5.0) sql/mysqld.cc: Merge with 4.1 sql/opt_range.cc: Merge with 4.1 sql/share/czech/errmsg.txt: Merge with 4.1 sql/share/danish/errmsg.txt: Merge with 4.1 sql/share/dutch/errmsg.txt: Merge with 4.1 sql/share/english/errmsg.txt: Merge with 4.1 sql/share/estonian/errmsg.txt: Merge with 4.1 sql/share/french/errmsg.txt: Merge with 4.1 sql/share/german/errmsg.txt: Merge with 4.1 sql/share/greek/errmsg.txt: Merge with 4.1 sql/share/hungarian/errmsg.txt: Merge with 4.1 sql/share/italian/errmsg.txt: Merge with 4.1 sql/share/japanese/errmsg.txt: Merge with 4.1 sql/share/korean/errmsg.txt: Merge with 4.1 sql/share/norwegian-ny/errmsg.txt: Merge with 4.1 sql/share/norwegian/errmsg.txt: Merge with 4.1 sql/share/polish/errmsg.txt: Merge with 4.1 sql/share/portuguese/errmsg.txt: Merge with 4.1 sql/share/romanian/errmsg.txt: Merge with 4.1 sql/share/russian/errmsg.txt: Merge with 4.1 sql/share/serbian/errmsg.txt: Merge with 4.1 sql/share/slovak/errmsg.txt: Merge with 4.1 sql/share/spanish/errmsg.txt: Merge with 4.1 sql/share/swedish/errmsg.txt: Merge with 4.1 sql/share/ukrainian/errmsg.txt: Merge with 4.1 sql/sql_base.cc: Merge with 4.1 sql/sql_class.cc: Merge with 4.1 Use arena code from 4.1 sql/sql_class.h: Merge with 4.1 Use arena code from 4.1 sql/sql_derived.cc: Merge with 4.1 sql/sql_lex.cc: Merge with 4.1 sql/sql_lex.h: Merge with 4.1 sql/sql_parse.cc: Merge with 4.1 sql/sql_prepare.cc: Merge with 4.1 sql/sql_select.cc: Merge with 4.1 sql/sql_table.cc: Merge with 4.1 sql/sql_union.cc: Merge with 4.1 sql/sql_yacc.yy: Merge with 4.1 sql/tztime.cc: Merge with 4.1 tests/client_test.c: Merge with 4.1
2004-09-06 14:14:10 +02:00
Item *item= func->create(expr,
Name resolution context added (BUG#6443) include/my_bitmap.h: new bitmap operation mysql-test/r/view.result: added warnings Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysql-test/t/view.test: Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysys/my_bitmap.c: new bitmap operation sql/field.h: index of field in table added sql/item.cc: Name resolution context added table list removed from fix_fields() arguments sql/item.h: Name resolution context added table list removed from fix_fields() arguments sql/item_cmpfunc.cc: table list removed from fix_fields() arguments sql/item_cmpfunc.h: table list removed from fix_fields() arguments sql/item_func.cc: table list removed from fix_fields() arguments sql/item_func.h: table list removed from fix_fields() arguments sql/item_row.cc: table list removed from fix_fields() arguments sql/item_row.h: table list removed from fix_fields() arguments sql/item_strfunc.cc: fixed server crash on NULL argument sql/item_strfunc.h: table list removed from fix_fields() arguments sql/item_subselect.cc: table list removed from fix_fields() arguments sql/item_subselect.h: table list removed from fix_fields() arguments sql/item_sum.cc: table list removed from fix_fields() arguments sql/item_sum.h: table list removed from fix_fields() arguments sql/item_timefunc.cc: table list removed from fix_fields() arguments sql/item_timefunc.h: table list removed from fix_fields() arguments sql/item_uniq.h: table list removed from fix_fields() arguments sql/log_event.cc: Name resolution context added sql/log_event.h: Name resolution context added sql/mysql_priv.h: Name resolution context added sql/set_var.cc: table list removed from fix_fields() arguments sql/share/errmsg.txt: new error message sql/sp.cc: Name resolution context added sql/sp_head.cc: table list removed from fix_fields() arguments sql/sp_head.h: Name resolution context added sql/sql_base.cc: table list removed from fix_fields() arguments Name resolution context added sql/sql_class.cc: renamed variable sql/sql_delete.cc: Name resolution context added sql/sql_derived.cc: Name resolution context added sql/sql_do.cc: table list removed from fix_fields() arguments sql/sql_handler.cc: Name resolution context added sql/sql_help.cc: Name resolution context added sql/sql_insert.cc: Name resolution context added table list removed from fix_fields() arguments sql/sql_lex.cc: Name resolution context added sql/sql_lex.h: removed resolve mode (information stored into name resolution context) sql/sql_load.cc: table list removed from fix_fields() arguments sql/sql_olap.cc: Name resolution context added sql/sql_parse.cc: Name resolution context added sql/sql_prepare.cc: table list removed from fix_fields() arguments sql/sql_select.cc: table list removed from fix_fields() arguments sql/sql_show.cc: Name resolution context added sql/sql_trigger.cc: table list removed from fix_fields() arguments sql/sql_udf.h: table list removed from fix_fields() arguments sql/sql_union.cc: Name resolution context added sql/sql_update.cc: Name resolution context added sql/sql_view.cc: Name resolution context added sql/sql_view.h: table list removed from fix_fields() arguments sql/sql_yacc.yy: Name resolution context added sql/table.cc: Name resolution context added merged view processing moved sql/table.h: merged view processing moved
2005-07-01 06:05:42 +02:00
new Item_ref_null_helper(&select_lex->context,
this,
Merge with 4.1 (Includes merge of arena code in 4.1 and 5.0) BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged client/mysql.cc: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/client_settings.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/examples/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged myisam/sort.c: Auto merged mysql-test/r/connect.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/func_in.result: Auto merged mysql-test/r/func_like.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/having.result: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/join.result: Auto merged mysql-test/r/key.result: Auto merged mysql-test/r/lowercase_table.result: Auto merged mysql-test/r/ndb_autodiscover.result: Auto merged mysql-test/r/null.result: Auto merged mysql-test/r/olap.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/rename.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/null.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/rpl_charset.test: Auto merged mysql-test/t/rpl_heap.test: Auto merged mysql-test/t/rpl_relayrotate.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/variables.test: Auto merged netware/mysql_test_run.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged scripts/mysql_install_db.sh: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_create.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_sum.cc: Auto merged sql/protocol.cc: Auto merged sql/records.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_list.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_string.h: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged client/mysqlbinlog.cc: Merge with 4.1 configure.in: Merge with 4.1 include/mysqld_error.h: Add new error message (1) from 4.1 mysql-test/mysql-test-run.sh: Merge with 4.1 mysql-test/r/func_gconcat.result: Merge with 4.1 mysql-test/r/func_if.result: Merge with 4.1 mysql-test/r/grant.result: Merge with 4.1 mysql-test/r/join_outer.result: Merge with 4.1 mysql-test/r/rpl_charset.result: Merge with 4.1 (This has to be fixed before pushing) mysql-test/r/system_mysql_db.result: Merge with 4.1. Added collation to new privileges mysql-test/t/grant.test: Merge with 4.1 mysql-test/t/grant_cache.test: Merge with 4.1 mysql-test/t/show_check.test: Merge with 4.1 sql/Makefile.am: Merge with 4.1 sql/item.cc: Merge with 4.1 sql/item_cmpfunc.cc: Merge with 4.1 (arena code) sql/item_subselect.cc: Merge with 4.1 sql/item_subselect.h: Merge with 4.1 sql/item_sum.cc: Merge with 4.1 sql/item_sum.h: Merge with 4.1 sql/log.cc: Merge with 4.1 (Remove code that is not relevant for 5.0) sql/mysqld.cc: Merge with 4.1 sql/opt_range.cc: Merge with 4.1 sql/share/czech/errmsg.txt: Merge with 4.1 sql/share/danish/errmsg.txt: Merge with 4.1 sql/share/dutch/errmsg.txt: Merge with 4.1 sql/share/english/errmsg.txt: Merge with 4.1 sql/share/estonian/errmsg.txt: Merge with 4.1 sql/share/french/errmsg.txt: Merge with 4.1 sql/share/german/errmsg.txt: Merge with 4.1 sql/share/greek/errmsg.txt: Merge with 4.1 sql/share/hungarian/errmsg.txt: Merge with 4.1 sql/share/italian/errmsg.txt: Merge with 4.1 sql/share/japanese/errmsg.txt: Merge with 4.1 sql/share/korean/errmsg.txt: Merge with 4.1 sql/share/norwegian-ny/errmsg.txt: Merge with 4.1 sql/share/norwegian/errmsg.txt: Merge with 4.1 sql/share/polish/errmsg.txt: Merge with 4.1 sql/share/portuguese/errmsg.txt: Merge with 4.1 sql/share/romanian/errmsg.txt: Merge with 4.1 sql/share/russian/errmsg.txt: Merge with 4.1 sql/share/serbian/errmsg.txt: Merge with 4.1 sql/share/slovak/errmsg.txt: Merge with 4.1 sql/share/spanish/errmsg.txt: Merge with 4.1 sql/share/swedish/errmsg.txt: Merge with 4.1 sql/share/ukrainian/errmsg.txt: Merge with 4.1 sql/sql_base.cc: Merge with 4.1 sql/sql_class.cc: Merge with 4.1 Use arena code from 4.1 sql/sql_class.h: Merge with 4.1 Use arena code from 4.1 sql/sql_derived.cc: Merge with 4.1 sql/sql_lex.cc: Merge with 4.1 sql/sql_lex.h: Merge with 4.1 sql/sql_parse.cc: Merge with 4.1 sql/sql_prepare.cc: Merge with 4.1 sql/sql_select.cc: Merge with 4.1 sql/sql_table.cc: Merge with 4.1 sql/sql_union.cc: Merge with 4.1 sql/sql_yacc.yy: Merge with 4.1 sql/tztime.cc: Merge with 4.1 tests/client_test.c: Merge with 4.1
2004-09-06 14:14:10 +02:00
select_lex->
ref_pointer_array,
(char *)"<ref>",
this->full_name()));
if (!abort_on_null && left_expr->maybe_null)
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
{
/*
We can encounter "NULL IN (SELECT ...)". Wrap the added condition
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
within a trig_cond.
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
*/
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
item= new Item_func_trig_cond(item, get_cond_guard(0));
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
}
if (!join_having)
item->name= (char*) in_having_cond;
if (fix_having(item, select_lex))
DBUG_RETURN(true);
*having_item= item;
}
else
{
Merge with 4.1 (Includes merge of arena code in 4.1 and 5.0) BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged client/mysql.cc: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/client_settings.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/examples/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged myisam/sort.c: Auto merged mysql-test/r/connect.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/func_in.result: Auto merged mysql-test/r/func_like.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/having.result: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/join.result: Auto merged mysql-test/r/key.result: Auto merged mysql-test/r/lowercase_table.result: Auto merged mysql-test/r/ndb_autodiscover.result: Auto merged mysql-test/r/null.result: Auto merged mysql-test/r/olap.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/rename.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/null.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/rpl_charset.test: Auto merged mysql-test/t/rpl_heap.test: Auto merged mysql-test/t/rpl_relayrotate.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/variables.test: Auto merged netware/mysql_test_run.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged scripts/mysql_install_db.sh: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_create.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_sum.cc: Auto merged sql/protocol.cc: Auto merged sql/records.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_list.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_string.h: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged client/mysqlbinlog.cc: Merge with 4.1 configure.in: Merge with 4.1 include/mysqld_error.h: Add new error message (1) from 4.1 mysql-test/mysql-test-run.sh: Merge with 4.1 mysql-test/r/func_gconcat.result: Merge with 4.1 mysql-test/r/func_if.result: Merge with 4.1 mysql-test/r/grant.result: Merge with 4.1 mysql-test/r/join_outer.result: Merge with 4.1 mysql-test/r/rpl_charset.result: Merge with 4.1 (This has to be fixed before pushing) mysql-test/r/system_mysql_db.result: Merge with 4.1. Added collation to new privileges mysql-test/t/grant.test: Merge with 4.1 mysql-test/t/grant_cache.test: Merge with 4.1 mysql-test/t/show_check.test: Merge with 4.1 sql/Makefile.am: Merge with 4.1 sql/item.cc: Merge with 4.1 sql/item_cmpfunc.cc: Merge with 4.1 (arena code) sql/item_subselect.cc: Merge with 4.1 sql/item_subselect.h: Merge with 4.1 sql/item_sum.cc: Merge with 4.1 sql/item_sum.h: Merge with 4.1 sql/log.cc: Merge with 4.1 (Remove code that is not relevant for 5.0) sql/mysqld.cc: Merge with 4.1 sql/opt_range.cc: Merge with 4.1 sql/share/czech/errmsg.txt: Merge with 4.1 sql/share/danish/errmsg.txt: Merge with 4.1 sql/share/dutch/errmsg.txt: Merge with 4.1 sql/share/english/errmsg.txt: Merge with 4.1 sql/share/estonian/errmsg.txt: Merge with 4.1 sql/share/french/errmsg.txt: Merge with 4.1 sql/share/german/errmsg.txt: Merge with 4.1 sql/share/greek/errmsg.txt: Merge with 4.1 sql/share/hungarian/errmsg.txt: Merge with 4.1 sql/share/italian/errmsg.txt: Merge with 4.1 sql/share/japanese/errmsg.txt: Merge with 4.1 sql/share/korean/errmsg.txt: Merge with 4.1 sql/share/norwegian-ny/errmsg.txt: Merge with 4.1 sql/share/norwegian/errmsg.txt: Merge with 4.1 sql/share/polish/errmsg.txt: Merge with 4.1 sql/share/portuguese/errmsg.txt: Merge with 4.1 sql/share/romanian/errmsg.txt: Merge with 4.1 sql/share/russian/errmsg.txt: Merge with 4.1 sql/share/serbian/errmsg.txt: Merge with 4.1 sql/share/slovak/errmsg.txt: Merge with 4.1 sql/share/spanish/errmsg.txt: Merge with 4.1 sql/share/swedish/errmsg.txt: Merge with 4.1 sql/share/ukrainian/errmsg.txt: Merge with 4.1 sql/sql_base.cc: Merge with 4.1 sql/sql_class.cc: Merge with 4.1 Use arena code from 4.1 sql/sql_class.h: Merge with 4.1 Use arena code from 4.1 sql/sql_derived.cc: Merge with 4.1 sql/sql_lex.cc: Merge with 4.1 sql/sql_lex.h: Merge with 4.1 sql/sql_parse.cc: Merge with 4.1 sql/sql_prepare.cc: Merge with 4.1 sql/sql_select.cc: Merge with 4.1 sql/sql_table.cc: Merge with 4.1 sql/sql_union.cc: Merge with 4.1 sql/sql_yacc.yy: Merge with 4.1 sql/tztime.cc: Merge with 4.1 tests/client_test.c: Merge with 4.1
2004-09-06 14:14:10 +02:00
Item *item= (Item*) select_lex->item_list.head();
if (select_lex->table_list.elements)
{
Item *having= item;
Item *orig_item= item;
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
item= func->create(expr, item);
if (!abort_on_null && orig_item->maybe_null)
fixed * without tables in IN bug fixed sunction-test select in IN bug fixed unions in subselect bug include/mysqld_error.h: new warning mysql-test/r/subselect.result: test of * without tables in IN test of sunction-test select in IN test of unions in subselect mysql-test/t/subselect.test: test of * without tables in IN test of sunction-test select in IN test of unions in subselect sql/item.cc: fixed * substitution without tables sql/item_subselect.cc: fixed subselect rewriting with function-test subselect sql/item_subselect.h: mechanism for subselect removing sql/share/czech/errmsg.txt: new warning sql/share/danish/errmsg.txt: new warning sql/share/dutch/errmsg.txt: new warning sql/share/english/errmsg.txt: new warning sql/share/estonian/errmsg.txt: new warning sql/share/french/errmsg.txt: new warning sql/share/german/errmsg.txt: new warning sql/share/greek/errmsg.txt: new warning sql/share/hungarian/errmsg.txt: new warning sql/share/italian/errmsg.txt: new warning sql/share/japanese/errmsg.txt: new warning sql/share/korean/errmsg.txt: new warning sql/share/norwegian-ny/errmsg.txt: new warning sql/share/norwegian/errmsg.txt: new warning sql/share/polish/errmsg.txt: new warning sql/share/portuguese/errmsg.txt: new warning sql/share/romanian/errmsg.txt: new warning sql/share/russian/errmsg.txt: new warning sql/share/serbian/errmsg.txt: new warning sql/share/slovak/errmsg.txt: new warning sql/share/spanish/errmsg.txt: new warning sql/share/swedish/errmsg.txt: new warning sql/share/ukrainian/errmsg.txt: new warning sql/sql_base.cc: fixed case on no name field in UNION subselect sql/sql_lex.cc: mechanisp of removing single subselect for optimisation purposes sql/sql_lex.h: mechanisp of removing single subselect for optimisation purposes sql/sql_parse.cc: error handling sql/sql_union.cc: fixed unions in subselect sql/sql_yacc.yy: fixed Lex->describe flag appearence
2002-11-28 18:29:26 +01:00
{
having= new Item_is_not_null_test(this, having);
if (left_expr->maybe_null)
{
if (!(having= new Item_func_trig_cond(having,
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
get_cond_guard(0))))
DBUG_RETURN(true);
}
having->name= (char*) in_having_cond;
if (fix_having(having, select_lex))
DBUG_RETURN(true);
*having_item= having;
item= new Item_cond_or(item,
new Item_func_isnull(orig_item));
}
/*
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
If we may encounter NULL IN (SELECT ...) and care whether subquery
result is NULL or FALSE, wrap condition in a trig_cond.
*/
if (!abort_on_null && left_expr->maybe_null)
{
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (!(item= new Item_func_trig_cond(item, get_cond_guard(0))))
DBUG_RETURN(true);
}
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
/*
TODO: figure out why the following is done here in
single_value_transformer but there is no corresponding action in
row_value_transformer?
*/
item->name= (char *) in_additional_cond;
if (!item->fixed && item->fix_fields(thd, 0))
DBUG_RETURN(true);
*where_item= item;
}
else
{
if (select_lex->master_unit()->is_union())
{
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
Item *new_having=
func->create(expr,
new Item_ref_null_helper(&select_lex->context, this,
BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol In the code that converts IN predicates to EXISTS predicates it is changing the select list elements to constant 1. Example : SELECT ... FROM ... WHERE a IN (SELECT c FROM ...) is transformed to : SELECT ... FROM ... WHERE EXISTS (SELECT 1 FROM ... HAVING a = c) However there can be no FROM clause in the IN subquery and it may not be a simple select : SELECT ... FROM ... WHERE a IN (SELECT f(..) AS c UNION SELECT ...) This query is transformed to : SELECT ... FROM ... WHERE EXISTS (SELECT 1 FROM (SELECT f(..) AS c UNION SELECT ...) x HAVING a = c) In the above query c in the HAVING clause is made to be an Item_null_helper (a subclass of Item_ref) pointing to the real Item_field (which is not referenced anywhere else in the query anymore). This is done because Item_ref_null_helper collects information whether there are NULL values in the result. This is OK for directly executed statements, because the Item_field pointed by the Item_null_helper is already fixed when the transformation is done. But when executed as a prepared statement all the Item instances are "un-fixed" before the recompilation of the prepared statement. So when the Item_null_helper gets fixed it discovers that the Item_field it points to is not fixed and issues an error. The remedy is to keep the original select list references when there are no tables in the FROM clause. So the above becomes : SELECT ... FROM ... WHERE EXISTS (SELECT c FROM (SELECT f(..) AS c UNION SELECT ...) x HAVING a = c) In this way c is referenced directly in the select list as well as by reference in the HAVING clause. So it gets correctly fixed even with prepared statements. And since the Item_null_helper subclass of Item_ref_null_helper is not used anywhere else it's taken out. mysql-test/r/ps_11bugs.result: Test case for the bug mysql-test/r/subselect.result: Explain updated because of the tranformation mysql-test/t/ps_11bugs.test: Testcase for the bug sql/item.cc: Taking out Item_null_helper as it's no longer needed sql/item.h: Taking out Item_null_helper as it's no longer needed sql/item_subselect.cc: The described change to the IN->EXISTS transformation
2006-04-28 11:23:31 +02:00
select_lex->ref_pointer_array,
(char *)"<no matter>",
(char *)"<result>"));
if (!abort_on_null && left_expr->maybe_null)
{
if (!(new_having= new Item_func_trig_cond(new_having,
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
get_cond_guard(0))))
DBUG_RETURN(true);
}
new_having->name= (char*) in_having_cond;
if (fix_having(new_having, select_lex))
DBUG_RETURN(true);
*having_item= new_having;
}
else
DBUG_ASSERT(false);
}
}
DBUG_RETURN(false);
}
Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log Docs/mysqld_error.txt: Updated error messages Makefile.am: Added missing SSL library (Should be in source distribution) configure.in: Added missing SSL library include/sql_common.h: Move duplicated prototypes innobase/os/os0file.c: Added comment for line that could be removed innobase/srv/srv0srv.c: Added comment for line that could be removed innobase/srv/srv0start.c: Added comment for line that could be removed innobase/trx/trx0sys.c: Added cast to remove compiler warning isam/isamchk.c: Fixed compiler warning libmysql/conf_to_src.c: Include files in proper order myisam/mi_check.c: Removed else part that caused compiler warning myisam/mi_delete.c: Added cast myisam/mi_page.c: Added cast myisam/mi_preload.c: Added cast myisam/mi_write.c: Added cast myisam/myisampack.c: changed 'byte' to 'current_byte' to avoid compiler warnings mysql-test/mysql-test-run.sh: Removed start-from as test '<' is not portable and this can easily be done from command line mysys/hash.c: Added cast mysys/mf_wcomp.c: Removed not reached line mysys/my_append.c: Fixed include file order to get this more portable mysys/my_copy.c: Fixed include file order to get this more portable mysys/my_redel.c: Fixed include file order to get this more portable sql-common/client.c: More DBUG_PRINT sql-common/pack.c: Added casts becasue Fortre compiler apparently compares (ulonglong) < (longlong) as signed sql/ha_heap.cc: Changed variable names to not cause hidden variables sql/ha_innodb.cc: Changed variable names to not cause hidden variables sql/item.cc: Changed variable names to not cause hidden variables sql/item.h: Changed variable names to not cause hidden variables sql/item_cmpfunc.h: Changed variable names to not cause hidden variables sql/item_func.cc: Changed variable names to not cause hidden variables sql/item_subselect.cc: Changed variable names to not cause hidden variables sql/item_subselect.h: Changed variable names to not cause hidden variables sql/item_sum.cc: Changed variable names to not cause hidden variables sql/item_timefunc.cc: Changed variable names to not cause hidden variables sql/log.cc: Changed variable names to not cause hidden variables sql/protocol.cc: Changed variable names to not cause hidden variables sql/protocol.h: Changed variable names to not cause hidden variables Remove function not declared in protocol.cc sql/protocol_cursor.cc: Changed variable names to not cause hidden variables sql/set_var.cc: Added a lot of 'version_xxx' strings Changed 'bdb_version' to 'version_bdb' sql/sql_class.cc: Changed variable names to not cause hidden variables Add TMP_TABLE_PARAM::init() to allow one to initialize structure several times sql/sql_class.h: Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) sql/sql_derived.cc: Avoid copying TMP_TABLE_PARAM (Use class version instead) sql/sql_error.cc: More DBUG sql/sql_help.cc: Fixed compiler warning sql/sql_lex.cc: Changed variable names to not cause hidden variables sql/sql_list.h: Changed variable names to not cause hidden variables sql/sql_parse.cc: Changed variable names to not cause hidden variables sql/sql_select.cc: Changed variable names to not cause hidden variables Ensure that you don't send NULL to printf() for %s Fixed problem with printing sub selects to debug log sql/sql_select.h: Changed variable names to not cause hidden variables sql/sql_union.cc: Changed variable names to not cause hidden variables Don't use local copy of TMP_TABLE_PARAM (Caused core dump on Solaris) sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Remove warning strings/conf_to_src.c: Fixed include file order
2003-11-28 11:18:13 +01:00
/**
Wrap a multi-column IN/ALL/ANY subselect into an Item_in_optimizer.
@param join Join object of the subquery (i.e. 'child' join).
@details
The subquery predicate is wrapped into an Item_in_optimizer. Later the query
optimization phase chooses whether the subquery under the Item_in_optimizer
will be further transformed into an equivalent correlated EXISTS by injecting
additional predicates, or will be executed via subquery materialization in its
unmodified form.
@retval false The subquery was transformed
@retval true Error
*/
bool
Item_in_subselect::row_value_transformer(JOIN *join)
{
Merge with 4.1 (Includes merge of arena code in 4.1 and 5.0) BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged client/mysql.cc: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/client_settings.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/examples/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged myisam/sort.c: Auto merged mysql-test/r/connect.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/func_in.result: Auto merged mysql-test/r/func_like.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/having.result: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/join.result: Auto merged mysql-test/r/key.result: Auto merged mysql-test/r/lowercase_table.result: Auto merged mysql-test/r/ndb_autodiscover.result: Auto merged mysql-test/r/null.result: Auto merged mysql-test/r/olap.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/rename.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/null.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/rpl_charset.test: Auto merged mysql-test/t/rpl_heap.test: Auto merged mysql-test/t/rpl_relayrotate.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/variables.test: Auto merged netware/mysql_test_run.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged scripts/mysql_install_db.sh: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_create.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_sum.cc: Auto merged sql/protocol.cc: Auto merged sql/records.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_list.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_string.h: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged client/mysqlbinlog.cc: Merge with 4.1 configure.in: Merge with 4.1 include/mysqld_error.h: Add new error message (1) from 4.1 mysql-test/mysql-test-run.sh: Merge with 4.1 mysql-test/r/func_gconcat.result: Merge with 4.1 mysql-test/r/func_if.result: Merge with 4.1 mysql-test/r/grant.result: Merge with 4.1 mysql-test/r/join_outer.result: Merge with 4.1 mysql-test/r/rpl_charset.result: Merge with 4.1 (This has to be fixed before pushing) mysql-test/r/system_mysql_db.result: Merge with 4.1. Added collation to new privileges mysql-test/t/grant.test: Merge with 4.1 mysql-test/t/grant_cache.test: Merge with 4.1 mysql-test/t/show_check.test: Merge with 4.1 sql/Makefile.am: Merge with 4.1 sql/item.cc: Merge with 4.1 sql/item_cmpfunc.cc: Merge with 4.1 (arena code) sql/item_subselect.cc: Merge with 4.1 sql/item_subselect.h: Merge with 4.1 sql/item_sum.cc: Merge with 4.1 sql/item_sum.h: Merge with 4.1 sql/log.cc: Merge with 4.1 (Remove code that is not relevant for 5.0) sql/mysqld.cc: Merge with 4.1 sql/opt_range.cc: Merge with 4.1 sql/share/czech/errmsg.txt: Merge with 4.1 sql/share/danish/errmsg.txt: Merge with 4.1 sql/share/dutch/errmsg.txt: Merge with 4.1 sql/share/english/errmsg.txt: Merge with 4.1 sql/share/estonian/errmsg.txt: Merge with 4.1 sql/share/french/errmsg.txt: Merge with 4.1 sql/share/german/errmsg.txt: Merge with 4.1 sql/share/greek/errmsg.txt: Merge with 4.1 sql/share/hungarian/errmsg.txt: Merge with 4.1 sql/share/italian/errmsg.txt: Merge with 4.1 sql/share/japanese/errmsg.txt: Merge with 4.1 sql/share/korean/errmsg.txt: Merge with 4.1 sql/share/norwegian-ny/errmsg.txt: Merge with 4.1 sql/share/norwegian/errmsg.txt: Merge with 4.1 sql/share/polish/errmsg.txt: Merge with 4.1 sql/share/portuguese/errmsg.txt: Merge with 4.1 sql/share/romanian/errmsg.txt: Merge with 4.1 sql/share/russian/errmsg.txt: Merge with 4.1 sql/share/serbian/errmsg.txt: Merge with 4.1 sql/share/slovak/errmsg.txt: Merge with 4.1 sql/share/spanish/errmsg.txt: Merge with 4.1 sql/share/swedish/errmsg.txt: Merge with 4.1 sql/share/ukrainian/errmsg.txt: Merge with 4.1 sql/sql_base.cc: Merge with 4.1 sql/sql_class.cc: Merge with 4.1 Use arena code from 4.1 sql/sql_class.h: Merge with 4.1 Use arena code from 4.1 sql/sql_derived.cc: Merge with 4.1 sql/sql_lex.cc: Merge with 4.1 sql/sql_lex.h: Merge with 4.1 sql/sql_parse.cc: Merge with 4.1 sql/sql_prepare.cc: Merge with 4.1 sql/sql_select.cc: Merge with 4.1 sql/sql_table.cc: Merge with 4.1 sql/sql_union.cc: Merge with 4.1 sql/sql_yacc.yy: Merge with 4.1 sql/tztime.cc: Merge with 4.1 tests/client_test.c: Merge with 4.1
2004-09-06 14:14:10 +02:00
SELECT_LEX *select_lex= join->select_lex;
uint cols_num= left_expr->cols();
DBUG_ENTER("Item_in_subselect::row_value_transformer");
// psergey: duplicated_subselect_card_check
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (select_lex->item_list.elements != cols_num)
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
my_error(ER_OPERAND_COLUMNS, MYF(0), cols_num);
DBUG_RETURN(true);
}
/*
Wrap the current IN predicate in an Item_in_optimizer. The actual
substitution in the Item tree takes place in Item_subselect::fix_fields.
*/
if (!substitution)
{
//first call for this unit
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
SELECT_LEX_UNIT *master_unit= select_lex->master_unit();
substitution= optimizer;
Fixed compiler warnings in a lot of files Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined client/get_password.c: Fixed compiler warning cmd-line-utils/readline/bind.c: Fixed compiler warning cmd-line-utils/readline/chardefs.h: Fixed compiler warning by adding marco to be used when largest_char is 255 cmd-line-utils/readline/display.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/histexpand.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/history.c: Fixed compiler warnings by adding cast cmd-line-utils/readline/text.c: Fixed compiler warnings by removing not accessed variables and adding casts dbug/dbug.c: Fixed compiler warnings by changing types include/mysql_com.h: Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value libmysql/libmysql.c: Fixed compiler warning mysql-test/t/query_cache_debug.test: Mark test as BIG as it uses a lot of memory mysys/mf_iocache2.c: Fixed compiler warnings by adding cast sql/event_data_objects.cc: Fixed compiler warnings by removing not used code sql/events.cc: Fixed compiler warnings by removing not used code sql/field.cc: Fixed compiler warnings by adding cast and removed not accessed variables sql/ha_partition.cc: Fixed compiler warnings by removing not used code sql/item.cc: Fixed compiler warnings by removing not accessed variables Use IMPOSSIBLE_RESULT instead of (Item_result)-1 sql/item_cmpfunc.cc: Fixed compiler warnings by removing not accessed variables sql/item_func.cc: Fixed compiler warnings by removing not used code and not accessed variables Added IMPOSSIBLE_RESULT sql/item_subselect.cc: Fixed compiler warnings by removing not accessed variables sql/item_xmlfunc.cc: Fixed forgotten setting of xpath->error sql/log.cc: Fixed compiler warnings by removing not accessed variables sql/log_event.cc: Added IMPOSSIBLE_RESULT into switch Fixed wrong usage of DBUG_ASSERT(1) Removed always true DBUG_ASSERT() sql/mysqld.cc: Fixed compiler warnings by adding casts for ULONG_MAX sql/opt_sum.cc: Fixed compiler warnings by removing not used code Removed wrong DBUG_ASSERT() sql/partition_info.cc: Fixed compiler warnings by removing not accessed variables sql/rpl_injector.h: Removed always true part from DBUG_ASSERT() to remove compiler warning sql/spatial.cc: Fixed compiler warnings by removing not accessed variables sql/sql_acl.cc: Fixed compiler warnings by removing not accessed variables sql/sql_base.cc: Fixed compiler warnings by removing not accessed variables sql/sql_cache.cc: Fixed compiler warnings by removing not accessed variables sql/sql_class.cc: Fixed compiler warnings by: - Removing always true part from DBUG_ASSERT() - Removing not used code - Added IMPOSSIBLE_RESULT into switch sql/sql_load.cc: Fixed compiler warnings by removing not accessed variables sql/sql_parse.cc: Fixed compiler warnings by: - Removing not accessed variables - Removing always true part from DBUG_ASSERT() - Removing not used code sql/sql_plugin.cc: Added comment sql/sql_prepare.cc: Fixed compiler warnings by removing not accessed variables sql/sql_show.cc: Fixed compiler warnings by using correct cast sql/sql_table.cc: Fixed compiler warnings by removing not used code and removing not accessed variables sql/table.cc: Fixed compiler warnings by removing not accessed variables sql/time.cc: Fixed wrong DBUG_ASSERT(1) storage/maria/unittest/Makefile.am: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_consist.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_single.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined tests/mysql_client_test.c: Fixed compiler warnings by removing not accessed variables and changing types
2008-02-13 20:27:12 +01:00
SELECT_LEX *current= thd->lex->current_select;
thd->lex->current_select= current->return_after_parsing();
//optimizer never use Item **ref => we can pass 0 as parameter
Name resolution context added (BUG#6443) include/my_bitmap.h: new bitmap operation mysql-test/r/view.result: added warnings Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysql-test/t/view.test: Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysys/my_bitmap.c: new bitmap operation sql/field.h: index of field in table added sql/item.cc: Name resolution context added table list removed from fix_fields() arguments sql/item.h: Name resolution context added table list removed from fix_fields() arguments sql/item_cmpfunc.cc: table list removed from fix_fields() arguments sql/item_cmpfunc.h: table list removed from fix_fields() arguments sql/item_func.cc: table list removed from fix_fields() arguments sql/item_func.h: table list removed from fix_fields() arguments sql/item_row.cc: table list removed from fix_fields() arguments sql/item_row.h: table list removed from fix_fields() arguments sql/item_strfunc.cc: fixed server crash on NULL argument sql/item_strfunc.h: table list removed from fix_fields() arguments sql/item_subselect.cc: table list removed from fix_fields() arguments sql/item_subselect.h: table list removed from fix_fields() arguments sql/item_sum.cc: table list removed from fix_fields() arguments sql/item_sum.h: table list removed from fix_fields() arguments sql/item_timefunc.cc: table list removed from fix_fields() arguments sql/item_timefunc.h: table list removed from fix_fields() arguments sql/item_uniq.h: table list removed from fix_fields() arguments sql/log_event.cc: Name resolution context added sql/log_event.h: Name resolution context added sql/mysql_priv.h: Name resolution context added sql/set_var.cc: table list removed from fix_fields() arguments sql/share/errmsg.txt: new error message sql/sp.cc: Name resolution context added sql/sp_head.cc: table list removed from fix_fields() arguments sql/sp_head.h: Name resolution context added sql/sql_base.cc: table list removed from fix_fields() arguments Name resolution context added sql/sql_class.cc: renamed variable sql/sql_delete.cc: Name resolution context added sql/sql_derived.cc: Name resolution context added sql/sql_do.cc: table list removed from fix_fields() arguments sql/sql_handler.cc: Name resolution context added sql/sql_help.cc: Name resolution context added sql/sql_insert.cc: Name resolution context added table list removed from fix_fields() arguments sql/sql_lex.cc: Name resolution context added sql/sql_lex.h: removed resolve mode (information stored into name resolution context) sql/sql_load.cc: table list removed from fix_fields() arguments sql/sql_olap.cc: Name resolution context added sql/sql_parse.cc: Name resolution context added sql/sql_prepare.cc: table list removed from fix_fields() arguments sql/sql_select.cc: table list removed from fix_fields() arguments sql/sql_show.cc: Name resolution context added sql/sql_trigger.cc: table list removed from fix_fields() arguments sql/sql_udf.h: table list removed from fix_fields() arguments sql/sql_union.cc: Name resolution context added sql/sql_update.cc: Name resolution context added sql/sql_view.cc: Name resolution context added sql/sql_view.h: table list removed from fix_fields() arguments sql/sql_yacc.yy: Name resolution context added sql/table.cc: Name resolution context added merged view processing moved sql/table.h: merged view processing moved
2005-07-01 06:05:42 +02:00
if (!optimizer || optimizer->fix_left(thd, 0))
{
thd->lex->current_select= current;
DBUG_RETURN(true);
}
// we will refer to upper level cache array => we have to save it in PS
optimizer->keep_top_level_cache();
thd->lex->current_select= current;
/*
The uncacheable property controls a number of actions, e.g. whether to
save/restore (via init_save_join_tab/restore_tmp) the original JOIN for
plans with a temp table where the original JOIN was overriden by
make_simple_join. The UNCACHEABLE_EXPLAIN is ignored by EXPLAIN, thus
non-correlated subqueries will not appear as such to EXPLAIN.
*/
master_unit->uncacheable|= UNCACHEABLE_EXPLAIN;
select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
}
DBUG_RETURN(false);
}
/**
Create the predicates needed to transform a multi-column IN/ALL/ANY
subselect into a correlated EXISTS via predicate injection.
@details
The correlated predicates are created as follows:
- If the subquery has aggregates, GROUP BY, or HAVING, convert to
(l1, l2, l3) IN (SELECT v1, v2, v3 ... HAVING having)
=>
EXISTS (SELECT ... HAVING having and
(l1 = v1 or is null v1) and
(l2 = v2 or is null v2) and
(l3 = v3 or is null v3) and
is_not_null_test(v1) and
is_not_null_test(v2) and
is_not_null_test(v3))
where is_not_null_test used to register nulls in case if we have
not found matching to return correct NULL value.
- Otherwise (no aggregates/GROUP BY/HAVING) convert the subquery as follows:
(l1, l2, l3) IN (SELECT v1, v2, v3 ... WHERE where)
=>
EXISTS (SELECT ... WHERE where and
(l1 = v1 or is null v1) and
(l2 = v2 or is null v2) and
(l3 = v3 or is null v3)
HAVING is_not_null_test(v1) and
is_not_null_test(v2) and
is_not_null_test(v3))
where is_not_null_test registers NULLs values but reject rows.
in case when we do not need correct NULL, we have simplier construction:
EXISTS (SELECT ... WHERE where and
(l1 = v1) and
(l2 = v2) and
(l3 = v3)
@param join[in] Join object of the subquery (i.e. 'child' join).
@param where_item[out] the in-to-exists addition to the where clause
@param having_item[out] the in-to-exists addition to the having clause
@retval false If the new conditions were created successfully
@retval true Error
*/
bool
Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item **where_item,
Item **having_item)
{
SELECT_LEX *select_lex= join->select_lex;
uint cols_num= left_expr->cols();
/*
The non-transformed HAVING clause of 'join' may be stored in two ways
during JOIN::optimize: this->tmp_having= this->having; this->having= 0;
*/
Item* join_having= join->having ? join->having : join->tmp_having;
bool is_having_used= (join_having || select_lex->with_sum_func ||
select_lex->group_list.first ||
!select_lex->table_list.elements);
DBUG_ENTER("Item_in_subselect::create_row_in_to_exists_cond");
*where_item= NULL;
*having_item= NULL;
if (is_having_used)
{
/* TODO: say here explicitly if the order of AND parts matters or not. */
Item *item_having_part2= 0;
for (uint i= 0; i < cols_num; i++)
{
Fixed compiler warnings found by gcc 4.3.2 - Added braces around expressions with &&, ||, & and | - Added empty line before ; for empty while and for loops - Added () around if with assignments - Removed const before function returning simple type Changed BUILD scripts to not build with NDB BUILD/SETUP.sh: By default, don't build ndb with --max in Maria tree. NDB is not kept up to date anyway in 5.1 client/mysql.cc: Added braces around && to get rid of compiler warnings sql/event_db_repository.cc: Added braces around && to get rid of compiler warnings sql/events.cc: Added braces around && to get rid of compiler warnings sql/field.cc: Added braces around && to get rid of compiler warnings Fixed for loops sql/field.h: Added braces around & to get rid of compiler warnings sql/field_conv.cc: Added braces around && to get rid of compiler warnings Fixed bug when copying between DATETIME fields and strict dates are used Removed not needeed else sql/gstream.cc: Added braces around && to get rid of compiler warnings sql/ha_ndbcluster.cc: Added braces around && to get rid of compiler warnings Added {} to get rid of compiler warnings sql/handler.cc: Added braces around && to get rid of compiler warnings sql/item.cc: Added braces around && to get rid of compiler warnings sql/item_cmpfunc.cc: Added braces around && to get rid of compiler warnings Removed some not needed space sql/item_func.cc: Added braces around && to get rid of compiler warnings sql/item_strfunc.cc: Added braces around && to get rid of compiler warnings sql/item_subselect.cc: Added braces around && to get rid of compiler warnings sql/item_sum.cc: Added braces around && to get rid of compiler warnings sql/item_timefunc.cc: Added braces around && to get rid of compiler warnings sql/item_xmlfunc.cc: Added empty line before ; for empty while and for loops sql/log.cc: Added braces around && to get rid of compiler warnings sql/log_event.cc: Added braces around && to get rid of compiler warnings Removed not needed else sql/log_event_old.cc: Added braces around && to get rid of compiler warnings sql/opt_range.cc: Added braces around && to get rid of compiler warnings sql/opt_sum.cc: Added braces around && to get rid of compiler warnings sql/set_var.cc: Added empty line before ; for empty while and for loops Added () around if with assignments sql/slave.cc: Added braces around && to get rid of compiler warnings Added empty line before ; for empty while and for loops sql/spatial.h: Added braces around && to get rid of compiler warnings sql/sql_acl.cc: Added braces around && to get rid of compiler warnings sql/sql_analyse.cc: Added empty line before ; for empty while and for loops sql/sql_base.cc: Added braces around && to get rid of compiler warnings sql/sql_connect.cc: Added braces around && to get rid of compiler warnings sql/sql_db.cc: Added braces around && to get rid of compiler warnings sql/sql_delete.cc: Added braces around && to get rid of compiler warnings sql/sql_help.cc: Added empty line before ; for empty while and for loops sql/sql_insert.cc: Added braces around && to get rid of compiler warnings Added () around if with assignments sql/sql_lex.cc: Cast char array references to uchar; Fixed wrong array referencing when using characters > ASCII 128 in SQL statments Added empty line before ; for empty while and for loops Trivial indent fixes Added braces around && to get rid of compiler warnings sql/sql_load.cc: Added braces around && to get rid of compiler warnings sql/sql_parse.cc: Added braces around && to get rid of compiler warnings sql/sql_partition.cc: Added braces around && to get rid of compiler warnings sql/sql_plugin.cc: Fixed bug in detecing if option variable should be readonly Added empty line before ; for empty while and for loops sql/sql_prepare.cc: Added braces around && to get rid of compiler warnings sql/sql_select.cc: Added braces around && to get rid of compiler warnings Added () around if with assignments Added empty line before ; for empty while and for loops sql/sql_show.cc: Added braces around && to get rid of compiler warnings sql/sql_table.cc: Added braces around && to get rid of compiler warnings sql/sql_trigger.cc: Added braces around && to get rid of compiler warnings sql/sql_update.cc: Added braces around && to get rid of compiler warnings sql/sql_yacc.yy: Added braces around && to get rid of compiler warnings sql/table.cc: Added braces around && to get rid of compiler warnings sql/table.h: Added braces around && to get rid of compiler warnings sql/time.cc: Added braces around && to get rid of compiler warnings sql/tztime.cc: Added braces around && to get rid of compiler warnings sql/uniques.cc: Added braces around && to get rid of compiler warnings storage/federated/ha_federated.cc: Fixed bug in testing of variable to ha_info() (Not critical) storage/heap/ha_heap.cc: Added braces around && to get rid of compiler warnings storage/maria/ha_maria.cc: Fixed bug: Mark that maria_log_dir_path is readonly Added braces around && to get rid of compiler warnings storage/ndb/include/ndbapi/NdbEventOperation.hpp: Removed const before function returning simple type storage/ndb/include/ndbapi/NdbOperation.hpp: Removed const before function returning simple type storage/ndb/src/ndbapi/Ndb.cpp: Added empty line before ; for empty while and for loops storage/ndb/src/ndbapi/NdbEventOperation.cpp: Removed const before function returning simple type storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp: Removed const before function returning simple type storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp: Removed const before function returning simple type storage/ndb/src/ndbapi/NdbRecAttr.cpp: Added empty line before ; for empty while and for loops storage/ndb/src/ndbapi/TransporterFacade.hpp: Added braces around && to get rid of compiler warnings
2009-01-31 22:22:44 +01:00
DBUG_ASSERT((left_expr->fixed &&
select_lex->ref_pointer_array[i]->fixed) ||
(select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
Item_ref::OUTER_REF));
if (select_lex->ref_pointer_array[i]->
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
check_cols(left_expr->element_index(i)->cols()))
DBUG_RETURN(true);
Item *item_eq=
new Item_func_eq(new
2006-08-24 18:56:28 +02:00
Item_ref(&select_lex->context,
(*optimizer->get_cache())->
addr(i),
(char *)"<no matter>",
(char *)in_left_expr_name),
new
2006-08-24 18:56:28 +02:00
Item_ref(&select_lex->context,
select_lex->ref_pointer_array + i,
(char *)"<no matter>",
(char *)"<list ref>"));
Item *item_isnull=
new Item_func_isnull(new
2006-08-24 18:56:28 +02:00
Item_ref(&select_lex->context,
select_lex->ref_pointer_array+i,
(char *)"<no matter>",
(char *)"<list ref>"));
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
Item *col_item= new Item_cond_or(item_eq, item_isnull);
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
{
if (!(col_item= new Item_func_trig_cond(col_item, get_cond_guard(i))))
DBUG_RETURN(true);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
}
*having_item= and_items(*having_item, col_item);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
Item *item_nnull_test=
new Item_is_not_null_test(this,
new Item_ref(&select_lex->context,
select_lex->
ref_pointer_array + i,
(char *)"<no matter>",
(char *)"<list ref>"));
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
{
if (!(item_nnull_test=
new Item_func_trig_cond(item_nnull_test, get_cond_guard(i))))
DBUG_RETURN(true);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
}
item_having_part2= and_items(item_having_part2, item_nnull_test);
item_having_part2->top_level_item();
}
*having_item= and_items(*having_item, item_having_part2);
}
else
{
for (uint i= 0; i < cols_num; i++)
{
Item *item, *item_isnull;
Fixed compiler warnings found by gcc 4.3.2 - Added braces around expressions with &&, ||, & and | - Added empty line before ; for empty while and for loops - Added () around if with assignments - Removed const before function returning simple type Changed BUILD scripts to not build with NDB BUILD/SETUP.sh: By default, don't build ndb with --max in Maria tree. NDB is not kept up to date anyway in 5.1 client/mysql.cc: Added braces around && to get rid of compiler warnings sql/event_db_repository.cc: Added braces around && to get rid of compiler warnings sql/events.cc: Added braces around && to get rid of compiler warnings sql/field.cc: Added braces around && to get rid of compiler warnings Fixed for loops sql/field.h: Added braces around & to get rid of compiler warnings sql/field_conv.cc: Added braces around && to get rid of compiler warnings Fixed bug when copying between DATETIME fields and strict dates are used Removed not needeed else sql/gstream.cc: Added braces around && to get rid of compiler warnings sql/ha_ndbcluster.cc: Added braces around && to get rid of compiler warnings Added {} to get rid of compiler warnings sql/handler.cc: Added braces around && to get rid of compiler warnings sql/item.cc: Added braces around && to get rid of compiler warnings sql/item_cmpfunc.cc: Added braces around && to get rid of compiler warnings Removed some not needed space sql/item_func.cc: Added braces around && to get rid of compiler warnings sql/item_strfunc.cc: Added braces around && to get rid of compiler warnings sql/item_subselect.cc: Added braces around && to get rid of compiler warnings sql/item_sum.cc: Added braces around && to get rid of compiler warnings sql/item_timefunc.cc: Added braces around && to get rid of compiler warnings sql/item_xmlfunc.cc: Added empty line before ; for empty while and for loops sql/log.cc: Added braces around && to get rid of compiler warnings sql/log_event.cc: Added braces around && to get rid of compiler warnings Removed not needed else sql/log_event_old.cc: Added braces around && to get rid of compiler warnings sql/opt_range.cc: Added braces around && to get rid of compiler warnings sql/opt_sum.cc: Added braces around && to get rid of compiler warnings sql/set_var.cc: Added empty line before ; for empty while and for loops Added () around if with assignments sql/slave.cc: Added braces around && to get rid of compiler warnings Added empty line before ; for empty while and for loops sql/spatial.h: Added braces around && to get rid of compiler warnings sql/sql_acl.cc: Added braces around && to get rid of compiler warnings sql/sql_analyse.cc: Added empty line before ; for empty while and for loops sql/sql_base.cc: Added braces around && to get rid of compiler warnings sql/sql_connect.cc: Added braces around && to get rid of compiler warnings sql/sql_db.cc: Added braces around && to get rid of compiler warnings sql/sql_delete.cc: Added braces around && to get rid of compiler warnings sql/sql_help.cc: Added empty line before ; for empty while and for loops sql/sql_insert.cc: Added braces around && to get rid of compiler warnings Added () around if with assignments sql/sql_lex.cc: Cast char array references to uchar; Fixed wrong array referencing when using characters > ASCII 128 in SQL statments Added empty line before ; for empty while and for loops Trivial indent fixes Added braces around && to get rid of compiler warnings sql/sql_load.cc: Added braces around && to get rid of compiler warnings sql/sql_parse.cc: Added braces around && to get rid of compiler warnings sql/sql_partition.cc: Added braces around && to get rid of compiler warnings sql/sql_plugin.cc: Fixed bug in detecing if option variable should be readonly Added empty line before ; for empty while and for loops sql/sql_prepare.cc: Added braces around && to get rid of compiler warnings sql/sql_select.cc: Added braces around && to get rid of compiler warnings Added () around if with assignments Added empty line before ; for empty while and for loops sql/sql_show.cc: Added braces around && to get rid of compiler warnings sql/sql_table.cc: Added braces around && to get rid of compiler warnings sql/sql_trigger.cc: Added braces around && to get rid of compiler warnings sql/sql_update.cc: Added braces around && to get rid of compiler warnings sql/sql_yacc.yy: Added braces around && to get rid of compiler warnings sql/table.cc: Added braces around && to get rid of compiler warnings sql/table.h: Added braces around && to get rid of compiler warnings sql/time.cc: Added braces around && to get rid of compiler warnings sql/tztime.cc: Added braces around && to get rid of compiler warnings sql/uniques.cc: Added braces around && to get rid of compiler warnings storage/federated/ha_federated.cc: Fixed bug in testing of variable to ha_info() (Not critical) storage/heap/ha_heap.cc: Added braces around && to get rid of compiler warnings storage/maria/ha_maria.cc: Fixed bug: Mark that maria_log_dir_path is readonly Added braces around && to get rid of compiler warnings storage/ndb/include/ndbapi/NdbEventOperation.hpp: Removed const before function returning simple type storage/ndb/include/ndbapi/NdbOperation.hpp: Removed const before function returning simple type storage/ndb/src/ndbapi/Ndb.cpp: Added empty line before ; for empty while and for loops storage/ndb/src/ndbapi/NdbEventOperation.cpp: Removed const before function returning simple type storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp: Removed const before function returning simple type storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp: Removed const before function returning simple type storage/ndb/src/ndbapi/NdbRecAttr.cpp: Added empty line before ; for empty while and for loops storage/ndb/src/ndbapi/TransporterFacade.hpp: Added braces around && to get rid of compiler warnings
2009-01-31 22:22:44 +01:00
DBUG_ASSERT((left_expr->fixed &&
select_lex->ref_pointer_array[i]->fixed) ||
(select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
Item_ref::OUTER_REF));
if (select_lex->ref_pointer_array[i]->
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
check_cols(left_expr->element_index(i)->cols()))
DBUG_RETURN(true);
item=
new Item_func_eq(new
Item_direct_ref(&select_lex->context,
(*optimizer->get_cache())->
addr(i),
(char *)"<no matter>",
(char *)in_left_expr_name),
new
Item_direct_ref(&select_lex->context,
select_lex->
ref_pointer_array+i,
(char *)"<no matter>",
(char *)"<list ref>"));
if (!abort_on_null)
{
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
Item *having_col_item=
new Item_is_not_null_test(this,
new
Item_ref(&select_lex->context,
select_lex->ref_pointer_array + i,
(char *)"<no matter>",
(char *)"<list ref>"));
item_isnull= new
Item_func_isnull(new
Item_direct_ref(&select_lex->context,
select_lex->
ref_pointer_array+i,
(char *)"<no matter>",
(char *)"<list ref>"));
item= new Item_cond_or(item, item_isnull);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
/*
TODO: why we create the above for cases where the right part
cant be NULL?
*/
if (left_expr->element_index(i)->maybe_null)
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
{
if (!(item= new Item_func_trig_cond(item, get_cond_guard(i))))
DBUG_RETURN(true);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (!(having_col_item=
new Item_func_trig_cond(having_col_item, get_cond_guard(i))))
DBUG_RETURN(true);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
}
*having_item= and_items(*having_item, having_col_item);
}
*where_item= and_items(*where_item, item);
}
}
if (*where_item)
{
if (!(*where_item)->fixed && (*where_item)->fix_fields(thd, 0))
DBUG_RETURN(true);
(*where_item)->top_level_item();
}
if (*having_item)
{
if (!join_having)
(*having_item)->name= (char*) in_having_cond;
if (fix_having(*having_item, select_lex))
DBUG_RETURN(true);
(*having_item)->top_level_item();
}
DBUG_RETURN(false);
}
bool
Item_in_subselect::select_transformer(JOIN *join)
{
return select_in_like_transformer(join);
}
2007-10-11 19:29:09 +02:00
/**
Create the predicates needed to transform an IN/ALL/ANY subselect into a
correlated EXISTS via predicate injection.
@param join_arg Join object of the subquery.
@retval FALSE ok
@retval TRUE error
*/
bool Item_in_subselect::create_in_to_exists_cond(JOIN *join_arg)
{
bool res;
DBUG_ASSERT(engine->engine_type() == subselect_engine::SINGLE_SELECT_ENGINE ||
engine->engine_type() == subselect_engine::UNION_ENGINE);
/*
TODO: the call to init_cond_guards allocates and initializes an
array of booleans that may not be used later because we may choose
materialization.
The two calls below to create_XYZ_cond depend on this boolean array.
If the dependency is removed, the call can be moved to a later phase.
*/
init_cond_guards();
if (left_expr->cols() == 1)
res= create_single_in_to_exists_cond(join_arg,
&(join_arg->in_to_exists_where),
&(join_arg->in_to_exists_having));
else
res= create_row_in_to_exists_cond(join_arg,
&(join_arg->in_to_exists_where),
&(join_arg->in_to_exists_having));
/*
The IN=>EXISTS transformation makes non-correlated subqueries correlated.
*/
if (!left_expr->const_item() || left_expr->is_expensive())
{
join_arg->select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
join_arg->select_lex->master_unit()->uncacheable|=
UNCACHEABLE_DEPENDENT_INJECTED;
}
/*
The uncacheable property controls a number of actions, e.g. whether to
save/restore (via init_save_join_tab/restore_tmp) the original JOIN for
plans with a temp table where the original JOIN was overriden by
make_simple_join. The UNCACHEABLE_EXPLAIN is ignored by EXPLAIN, thus
non-correlated subqueries will not appear as such to EXPLAIN.
*/
join_arg->select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
join_arg->select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
return (res);
}
/**
Transform an IN/ALL/ANY subselect into a correlated EXISTS via injecting
correlated in-to-exists predicates.
@param join_arg Join object of the subquery.
@retval FALSE ok
@retval TRUE error
*/
bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg)
{
SELECT_LEX *select_lex= join_arg->select_lex;
Item *where_item= join_arg->in_to_exists_where;
Item *having_item= join_arg->in_to_exists_having;
DBUG_ENTER("Item_in_subselect::inject_in_to_exists_cond");
if (where_item)
{
Fix LP BUG#718593 Analysis: Build_equal_items_for_cond() rewrites the WHERE clause in such a way, that it may merge the list join->cond_equal->current_level with the list of child Items in an AND condition of the WHERE clause. The place where this is done is: static COND *build_equal_items_for_cond(THD *thd, COND *cond, COND_EQUAL *inherited) { ... if (and_level) { args->concat(&eq_list); args->concat((List<Item> *)&cond_equal.current_level); } ... } As a result, later transformations on the WHERE clause may change the structure of the list join->cond_equal->current_level without knowing this. Specifically in this bug, Item_in_subselect::inject_in_to_exists_cond creates a new AND of the old WHERE clause and the IN->EXISTS conditions. It then calls fix_fields() for the new AND. Among other things, fix_fields flattens all nested ANDs into one by merging the AND argument lists. When there is a cond_equal for the JOIN, its list of Item_equal objects is attached to the end of the original AND. When a lower-level AND is merged into the top-level one, the argument list of the lower-level AND is concatenated to the list of multiple equalities in the upper-level AND. As a result, when substitute_for_best_equal_field processes the multiple equalities, it turns out that the multiple equality list contains the Items from the lower-level AND which were concatenated to the end of the join->cond_equal->current_level list. This results in a crash because this list must not contain any other Items except for the previously found Item_equal ones. Solution: When performing IN->EXIST predicate injection, and the where clause is an AND, detach the list of Item_equal objects before calling fix_fields on the injected where clause. After fix_fields is done, reattach back the multiple equalities list to the end of the argument list of the new AND.
2011-04-28 16:15:05 +02:00
List<Item> *and_args= NULL;
/*
If the top-level Item of the WHERE clause is an AND, detach the multiple
equality list that was attached to the end of the AND argument list by
build_equal_items_for_cond(). The multiple equalities must be detached
because fix_fields merges lower level AND arguments into the upper AND.
As a result, the arguments from lower-level ANDs are concatenated after
the multiple equalities. When the multiple equality list is treated as
such, it turns out that it contains non-Item_equal object which is wrong.
*/
if (join_arg->conds && join_arg->conds->type() == Item::COND_ITEM &&
((Item_cond*) join_arg->conds)->functype() == Item_func::COND_AND_FUNC)
{
and_args= ((Item_cond*) join_arg->conds)->argument_list();
if (join_arg->cond_equal)
and_args->disjoin((List<Item> *) &join_arg->cond_equal->current_level);
}
where_item= and_items(join_arg->conds, where_item);
if (!where_item->fixed && where_item->fix_fields(thd, 0))
DBUG_RETURN(true);
// TIMOUR TODO: call optimize_cond() for the new where clause
thd->change_item_tree(&select_lex->where, where_item);
select_lex->where->top_level_item();
join_arg->conds= select_lex->where;
Fix LP BUG#718593 Analysis: Build_equal_items_for_cond() rewrites the WHERE clause in such a way, that it may merge the list join->cond_equal->current_level with the list of child Items in an AND condition of the WHERE clause. The place where this is done is: static COND *build_equal_items_for_cond(THD *thd, COND *cond, COND_EQUAL *inherited) { ... if (and_level) { args->concat(&eq_list); args->concat((List<Item> *)&cond_equal.current_level); } ... } As a result, later transformations on the WHERE clause may change the structure of the list join->cond_equal->current_level without knowing this. Specifically in this bug, Item_in_subselect::inject_in_to_exists_cond creates a new AND of the old WHERE clause and the IN->EXISTS conditions. It then calls fix_fields() for the new AND. Among other things, fix_fields flattens all nested ANDs into one by merging the AND argument lists. When there is a cond_equal for the JOIN, its list of Item_equal objects is attached to the end of the original AND. When a lower-level AND is merged into the top-level one, the argument list of the lower-level AND is concatenated to the list of multiple equalities in the upper-level AND. As a result, when substitute_for_best_equal_field processes the multiple equalities, it turns out that the multiple equality list contains the Items from the lower-level AND which were concatenated to the end of the join->cond_equal->current_level list. This results in a crash because this list must not contain any other Items except for the previously found Item_equal ones. Solution: When performing IN->EXIST predicate injection, and the where clause is an AND, detach the list of Item_equal objects before calling fix_fields on the injected where clause. After fix_fields is done, reattach back the multiple equalities list to the end of the argument list of the new AND.
2011-04-28 16:15:05 +02:00
/* Attach back the list of multiple equalities to the new top-level AND. */
if (and_args && join_arg->cond_equal)
{
/* The argument list of the top-level AND may change after fix fields. */
and_args= ((Item_cond*) join_arg->conds)->argument_list();
List_iterator<Item_equal> li(join_arg->cond_equal->current_level);
Item_equal *elem;
while ((elem= li++))
{
and_args->push_back(elem);
}
Fix LP BUG#718593 Analysis: Build_equal_items_for_cond() rewrites the WHERE clause in such a way, that it may merge the list join->cond_equal->current_level with the list of child Items in an AND condition of the WHERE clause. The place where this is done is: static COND *build_equal_items_for_cond(THD *thd, COND *cond, COND_EQUAL *inherited) { ... if (and_level) { args->concat(&eq_list); args->concat((List<Item> *)&cond_equal.current_level); } ... } As a result, later transformations on the WHERE clause may change the structure of the list join->cond_equal->current_level without knowing this. Specifically in this bug, Item_in_subselect::inject_in_to_exists_cond creates a new AND of the old WHERE clause and the IN->EXISTS conditions. It then calls fix_fields() for the new AND. Among other things, fix_fields flattens all nested ANDs into one by merging the AND argument lists. When there is a cond_equal for the JOIN, its list of Item_equal objects is attached to the end of the original AND. When a lower-level AND is merged into the top-level one, the argument list of the lower-level AND is concatenated to the list of multiple equalities in the upper-level AND. As a result, when substitute_for_best_equal_field processes the multiple equalities, it turns out that the multiple equality list contains the Items from the lower-level AND which were concatenated to the end of the join->cond_equal->current_level list. This results in a crash because this list must not contain any other Items except for the previously found Item_equal ones. Solution: When performing IN->EXIST predicate injection, and the where clause is an AND, detach the list of Item_equal objects before calling fix_fields on the injected where clause. After fix_fields is done, reattach back the multiple equalities list to the end of the argument list of the new AND.
2011-04-28 16:15:05 +02:00
}
}
if (having_item)
{
Item* join_having= join_arg->having ? join_arg->having:join_arg->tmp_having;
having_item= and_items(join_having, having_item);
if (fix_having(having_item, select_lex))
DBUG_RETURN(true);
// TIMOUR TODO: call optimize_cond() for the new having clause
thd->change_item_tree(&select_lex->having, having_item);
select_lex->having->top_level_item();
join_arg->having= select_lex->having;
}
join_arg->thd->change_item_tree(&unit->global_parameters->select_limit,
new Item_int((int32) 1));
unit->select_limit_cnt= 1;
DBUG_RETURN(false);
}
2007-10-11 19:29:09 +02:00
/**
Prepare IN/ALL/ANY/SOME subquery transformation and call the appropriate
2007-10-11 19:29:09 +02:00
transformation function.
2007-10-11 19:29:09 +02:00
@param join JOIN object of transforming subquery
@notes
To decide which transformation procedure (scalar or row) applicable here
we have to call fix_fields() for the left expression to be able to call
cols() method on it. Also this method makes arena management for
underlying transformation methods.
@retval false OK
@retval true Error
*/
bool
Item_in_subselect::select_in_like_transformer(JOIN *join)
{
Query_arena *arena, backup;
Fixed compiler warnings in a lot of files Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined client/get_password.c: Fixed compiler warning cmd-line-utils/readline/bind.c: Fixed compiler warning cmd-line-utils/readline/chardefs.h: Fixed compiler warning by adding marco to be used when largest_char is 255 cmd-line-utils/readline/display.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/histexpand.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/history.c: Fixed compiler warnings by adding cast cmd-line-utils/readline/text.c: Fixed compiler warnings by removing not accessed variables and adding casts dbug/dbug.c: Fixed compiler warnings by changing types include/mysql_com.h: Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value libmysql/libmysql.c: Fixed compiler warning mysql-test/t/query_cache_debug.test: Mark test as BIG as it uses a lot of memory mysys/mf_iocache2.c: Fixed compiler warnings by adding cast sql/event_data_objects.cc: Fixed compiler warnings by removing not used code sql/events.cc: Fixed compiler warnings by removing not used code sql/field.cc: Fixed compiler warnings by adding cast and removed not accessed variables sql/ha_partition.cc: Fixed compiler warnings by removing not used code sql/item.cc: Fixed compiler warnings by removing not accessed variables Use IMPOSSIBLE_RESULT instead of (Item_result)-1 sql/item_cmpfunc.cc: Fixed compiler warnings by removing not accessed variables sql/item_func.cc: Fixed compiler warnings by removing not used code and not accessed variables Added IMPOSSIBLE_RESULT sql/item_subselect.cc: Fixed compiler warnings by removing not accessed variables sql/item_xmlfunc.cc: Fixed forgotten setting of xpath->error sql/log.cc: Fixed compiler warnings by removing not accessed variables sql/log_event.cc: Added IMPOSSIBLE_RESULT into switch Fixed wrong usage of DBUG_ASSERT(1) Removed always true DBUG_ASSERT() sql/mysqld.cc: Fixed compiler warnings by adding casts for ULONG_MAX sql/opt_sum.cc: Fixed compiler warnings by removing not used code Removed wrong DBUG_ASSERT() sql/partition_info.cc: Fixed compiler warnings by removing not accessed variables sql/rpl_injector.h: Removed always true part from DBUG_ASSERT() to remove compiler warning sql/spatial.cc: Fixed compiler warnings by removing not accessed variables sql/sql_acl.cc: Fixed compiler warnings by removing not accessed variables sql/sql_base.cc: Fixed compiler warnings by removing not accessed variables sql/sql_cache.cc: Fixed compiler warnings by removing not accessed variables sql/sql_class.cc: Fixed compiler warnings by: - Removing always true part from DBUG_ASSERT() - Removing not used code - Added IMPOSSIBLE_RESULT into switch sql/sql_load.cc: Fixed compiler warnings by removing not accessed variables sql/sql_parse.cc: Fixed compiler warnings by: - Removing not accessed variables - Removing always true part from DBUG_ASSERT() - Removing not used code sql/sql_plugin.cc: Added comment sql/sql_prepare.cc: Fixed compiler warnings by removing not accessed variables sql/sql_show.cc: Fixed compiler warnings by using correct cast sql/sql_table.cc: Fixed compiler warnings by removing not used code and removing not accessed variables sql/table.cc: Fixed compiler warnings by removing not accessed variables sql/time.cc: Fixed wrong DBUG_ASSERT(1) storage/maria/unittest/Makefile.am: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_consist.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_single.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined tests/mysql_client_test.c: Fixed compiler warnings by removing not accessed variables and changing types
2008-02-13 20:27:12 +01:00
SELECT_LEX *current= thd->lex->current_select;
const char *save_where= thd->where;
bool trans_res= true;
bool result;
DBUG_ENTER("Item_in_subselect::select_in_like_transformer");
/*
IN/SOME/ALL/ANY subqueries aren't support LIMIT clause. Without it
ORDER BY clause becomes meaningless thus we drop it here.
*/
for (SELECT_LEX *sl= current->master_unit()->first_select();
sl; sl= sl->next_select())
Bug#27219: Aggregate functions in ORDER BY. Mixing aggregate functions and non-grouping columns is not allowed in the ONLY_FULL_GROUP_BY mode. However in some cases the error wasn't thrown because of insufficient check. In order to check more thoroughly the new algorithm employs a list of outer fields used in a sum function and a SELECT_LEX::full_group_by_flag. Each non-outer field checked to find out whether it's aggregated or not and the current select is marked accordingly. All outer fields that are used under an aggregate function are added to the Item_sum::outer_fields list and later checked by the Item_sum::check_sum_func function. mysql-test/t/group_by.test: Added a test case for the bug#27219: Aggregate functions in ORDER BY. mysql-test/r/group_by.result: Added a test case for the bug#27219: Aggregate functions in ORDER BY. sql/sql_select.cc: Bug#27219: Aggregate functions in ORDER BY. Implementation of new check for mixing non aggregated fields and aggregation function in the ONLY_FULL_GROUP_BY mode. sql/sql_lex.cc: Bug#27219: Aggregate functions in ORDER BY. Initialization of the full_group_by_flag bitmap. SELECT_LEX::test_limit function doesn't reset ORDER BY clause anymore. sql/sql_lex.h: Bug#27219: Aggregate functions in ORDER BY. The full_group_by_flag is added to the SELECT_LEX class. sql/item_sum.h: Bug#27219: Aggregate functions in ORDER BY. The outer_fields list is added to the Item_sum class. sql/mysql_priv.h: Bug#27219: Aggregate functions in ORDER BY. Defined a set of constants used in the new check for mixing non aggregated fields and sum functions in the ONLY_FULL_GROUP_BY_MODE. sql/item_subselect.cc: Bug#27219: Aggregate functions in ORDER BY. The Item_in_subselect::select_in_like_transformer function now drops ORDER BY clause in all selects in a subquery. sql/item_sum.cc: Bug#27219: Aggregate functions in ORDER BY. Now the Item_sum::check_sum_func function now checks whether fields in the outer_fields list are aggregated or not and marks selects accordingly. sql/item.cc: Bug#27219: Aggregate functions in ORDER BY. Now the Item_field::fix_fields function checks whether the field is aggregated or not and marks its select_lex accordingly.
2008-03-27 17:49:32 +01:00
{
if (sl->join)
Bug#27219: Aggregate functions in ORDER BY. Mixing aggregate functions and non-grouping columns is not allowed in the ONLY_FULL_GROUP_BY mode. However in some cases the error wasn't thrown because of insufficient check. In order to check more thoroughly the new algorithm employs a list of outer fields used in a sum function and a SELECT_LEX::full_group_by_flag. Each non-outer field checked to find out whether it's aggregated or not and the current select is marked accordingly. All outer fields that are used under an aggregate function are added to the Item_sum::outer_fields list and later checked by the Item_sum::check_sum_func function. mysql-test/t/group_by.test: Added a test case for the bug#27219: Aggregate functions in ORDER BY. mysql-test/r/group_by.result: Added a test case for the bug#27219: Aggregate functions in ORDER BY. sql/sql_select.cc: Bug#27219: Aggregate functions in ORDER BY. Implementation of new check for mixing non aggregated fields and aggregation function in the ONLY_FULL_GROUP_BY mode. sql/sql_lex.cc: Bug#27219: Aggregate functions in ORDER BY. Initialization of the full_group_by_flag bitmap. SELECT_LEX::test_limit function doesn't reset ORDER BY clause anymore. sql/sql_lex.h: Bug#27219: Aggregate functions in ORDER BY. The full_group_by_flag is added to the SELECT_LEX class. sql/item_sum.h: Bug#27219: Aggregate functions in ORDER BY. The outer_fields list is added to the Item_sum class. sql/mysql_priv.h: Bug#27219: Aggregate functions in ORDER BY. Defined a set of constants used in the new check for mixing non aggregated fields and sum functions in the ONLY_FULL_GROUP_BY_MODE. sql/item_subselect.cc: Bug#27219: Aggregate functions in ORDER BY. The Item_in_subselect::select_in_like_transformer function now drops ORDER BY clause in all selects in a subquery. sql/item_sum.cc: Bug#27219: Aggregate functions in ORDER BY. Now the Item_sum::check_sum_func function now checks whether fields in the outer_fields list are aggregated or not and marks selects accordingly. sql/item.cc: Bug#27219: Aggregate functions in ORDER BY. Now the Item_field::fix_fields function checks whether the field is aggregated or not and marks its select_lex accordingly.
2008-03-27 17:49:32 +01:00
{
sl->join->order= 0;
sl->join->skip_sort_order= 1;
Bug#27219: Aggregate functions in ORDER BY. Mixing aggregate functions and non-grouping columns is not allowed in the ONLY_FULL_GROUP_BY mode. However in some cases the error wasn't thrown because of insufficient check. In order to check more thoroughly the new algorithm employs a list of outer fields used in a sum function and a SELECT_LEX::full_group_by_flag. Each non-outer field checked to find out whether it's aggregated or not and the current select is marked accordingly. All outer fields that are used under an aggregate function are added to the Item_sum::outer_fields list and later checked by the Item_sum::check_sum_func function. mysql-test/t/group_by.test: Added a test case for the bug#27219: Aggregate functions in ORDER BY. mysql-test/r/group_by.result: Added a test case for the bug#27219: Aggregate functions in ORDER BY. sql/sql_select.cc: Bug#27219: Aggregate functions in ORDER BY. Implementation of new check for mixing non aggregated fields and aggregation function in the ONLY_FULL_GROUP_BY mode. sql/sql_lex.cc: Bug#27219: Aggregate functions in ORDER BY. Initialization of the full_group_by_flag bitmap. SELECT_LEX::test_limit function doesn't reset ORDER BY clause anymore. sql/sql_lex.h: Bug#27219: Aggregate functions in ORDER BY. The full_group_by_flag is added to the SELECT_LEX class. sql/item_sum.h: Bug#27219: Aggregate functions in ORDER BY. The outer_fields list is added to the Item_sum class. sql/mysql_priv.h: Bug#27219: Aggregate functions in ORDER BY. Defined a set of constants used in the new check for mixing non aggregated fields and sum functions in the ONLY_FULL_GROUP_BY_MODE. sql/item_subselect.cc: Bug#27219: Aggregate functions in ORDER BY. The Item_in_subselect::select_in_like_transformer function now drops ORDER BY clause in all selects in a subquery. sql/item_sum.cc: Bug#27219: Aggregate functions in ORDER BY. Now the Item_sum::check_sum_func function now checks whether fields in the outer_fields list are aggregated or not and marks selects accordingly. sql/item.cc: Bug#27219: Aggregate functions in ORDER BY. Now the Item_field::fix_fields function checks whether the field is aggregated or not and marks its select_lex accordingly.
2008-03-27 17:49:32 +01:00
}
}
if (changed)
DBUG_RETURN(false);
thd->where= "IN/ALL/ANY subquery";
/*
In some optimisation cases we will not need this Item_in_optimizer
object, but we can't know it here, but here we need address correct
reference on left expresion.
2012-03-12 15:20:30 +01:00
note: we won't need Item_in_optimizer when handling degenerate cases
like "... IN (SELECT 1)"
*/
if (!optimizer)
{
arena= thd->activate_stmt_arena_if_needed(&backup);
result= (!(optimizer= new Item_in_optimizer(left_expr, this)));
if (arena)
thd->restore_active_arena(arena, &backup);
if (result)
goto err;
}
Fixed compiler warnings in a lot of files Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined client/get_password.c: Fixed compiler warning cmd-line-utils/readline/bind.c: Fixed compiler warning cmd-line-utils/readline/chardefs.h: Fixed compiler warning by adding marco to be used when largest_char is 255 cmd-line-utils/readline/display.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/histexpand.c: Fixed compiler warnings by removing not accessed variables cmd-line-utils/readline/history.c: Fixed compiler warnings by adding cast cmd-line-utils/readline/text.c: Fixed compiler warnings by removing not accessed variables and adding casts dbug/dbug.c: Fixed compiler warnings by changing types include/mysql_com.h: Added IMPOSSIBLE_RESULT to avoid compiler warnings when using (Item_result) -1 as a dummy value libmysql/libmysql.c: Fixed compiler warning mysql-test/t/query_cache_debug.test: Mark test as BIG as it uses a lot of memory mysys/mf_iocache2.c: Fixed compiler warnings by adding cast sql/event_data_objects.cc: Fixed compiler warnings by removing not used code sql/events.cc: Fixed compiler warnings by removing not used code sql/field.cc: Fixed compiler warnings by adding cast and removed not accessed variables sql/ha_partition.cc: Fixed compiler warnings by removing not used code sql/item.cc: Fixed compiler warnings by removing not accessed variables Use IMPOSSIBLE_RESULT instead of (Item_result)-1 sql/item_cmpfunc.cc: Fixed compiler warnings by removing not accessed variables sql/item_func.cc: Fixed compiler warnings by removing not used code and not accessed variables Added IMPOSSIBLE_RESULT sql/item_subselect.cc: Fixed compiler warnings by removing not accessed variables sql/item_xmlfunc.cc: Fixed forgotten setting of xpath->error sql/log.cc: Fixed compiler warnings by removing not accessed variables sql/log_event.cc: Added IMPOSSIBLE_RESULT into switch Fixed wrong usage of DBUG_ASSERT(1) Removed always true DBUG_ASSERT() sql/mysqld.cc: Fixed compiler warnings by adding casts for ULONG_MAX sql/opt_sum.cc: Fixed compiler warnings by removing not used code Removed wrong DBUG_ASSERT() sql/partition_info.cc: Fixed compiler warnings by removing not accessed variables sql/rpl_injector.h: Removed always true part from DBUG_ASSERT() to remove compiler warning sql/spatial.cc: Fixed compiler warnings by removing not accessed variables sql/sql_acl.cc: Fixed compiler warnings by removing not accessed variables sql/sql_base.cc: Fixed compiler warnings by removing not accessed variables sql/sql_cache.cc: Fixed compiler warnings by removing not accessed variables sql/sql_class.cc: Fixed compiler warnings by: - Removing always true part from DBUG_ASSERT() - Removing not used code - Added IMPOSSIBLE_RESULT into switch sql/sql_load.cc: Fixed compiler warnings by removing not accessed variables sql/sql_parse.cc: Fixed compiler warnings by: - Removing not accessed variables - Removing always true part from DBUG_ASSERT() - Removing not used code sql/sql_plugin.cc: Added comment sql/sql_prepare.cc: Fixed compiler warnings by removing not accessed variables sql/sql_show.cc: Fixed compiler warnings by using correct cast sql/sql_table.cc: Fixed compiler warnings by removing not used code and removing not accessed variables sql/table.cc: Fixed compiler warnings by removing not accessed variables sql/time.cc: Fixed wrong DBUG_ASSERT(1) storage/maria/unittest/Makefile.am: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_consist.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined storage/maria/unittest/ma_pagecache_single.c: Changed PAGE_SIZE to TEST_PAGE_SIZE to avoid compiler errors on systems where PAGE_SIZE is defined tests/mysql_client_test.c: Fixed compiler warnings by removing not accessed variables and changing types
2008-02-13 20:27:12 +01:00
thd->lex->current_select= current->return_after_parsing();
result= (!left_expr->fixed &&
Name resolution context added (BUG#6443) include/my_bitmap.h: new bitmap operation mysql-test/r/view.result: added warnings Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysql-test/t/view.test: Correct inserting data check (absence of default value) for view underlying tables (BUG#6443) mysys/my_bitmap.c: new bitmap operation sql/field.h: index of field in table added sql/item.cc: Name resolution context added table list removed from fix_fields() arguments sql/item.h: Name resolution context added table list removed from fix_fields() arguments sql/item_cmpfunc.cc: table list removed from fix_fields() arguments sql/item_cmpfunc.h: table list removed from fix_fields() arguments sql/item_func.cc: table list removed from fix_fields() arguments sql/item_func.h: table list removed from fix_fields() arguments sql/item_row.cc: table list removed from fix_fields() arguments sql/item_row.h: table list removed from fix_fields() arguments sql/item_strfunc.cc: fixed server crash on NULL argument sql/item_strfunc.h: table list removed from fix_fields() arguments sql/item_subselect.cc: table list removed from fix_fields() arguments sql/item_subselect.h: table list removed from fix_fields() arguments sql/item_sum.cc: table list removed from fix_fields() arguments sql/item_sum.h: table list removed from fix_fields() arguments sql/item_timefunc.cc: table list removed from fix_fields() arguments sql/item_timefunc.h: table list removed from fix_fields() arguments sql/item_uniq.h: table list removed from fix_fields() arguments sql/log_event.cc: Name resolution context added sql/log_event.h: Name resolution context added sql/mysql_priv.h: Name resolution context added sql/set_var.cc: table list removed from fix_fields() arguments sql/share/errmsg.txt: new error message sql/sp.cc: Name resolution context added sql/sp_head.cc: table list removed from fix_fields() arguments sql/sp_head.h: Name resolution context added sql/sql_base.cc: table list removed from fix_fields() arguments Name resolution context added sql/sql_class.cc: renamed variable sql/sql_delete.cc: Name resolution context added sql/sql_derived.cc: Name resolution context added sql/sql_do.cc: table list removed from fix_fields() arguments sql/sql_handler.cc: Name resolution context added sql/sql_help.cc: Name resolution context added sql/sql_insert.cc: Name resolution context added table list removed from fix_fields() arguments sql/sql_lex.cc: Name resolution context added sql/sql_lex.h: removed resolve mode (information stored into name resolution context) sql/sql_load.cc: table list removed from fix_fields() arguments sql/sql_olap.cc: Name resolution context added sql/sql_parse.cc: Name resolution context added sql/sql_prepare.cc: table list removed from fix_fields() arguments sql/sql_select.cc: table list removed from fix_fields() arguments sql/sql_show.cc: Name resolution context added sql/sql_trigger.cc: table list removed from fix_fields() arguments sql/sql_udf.h: table list removed from fix_fields() arguments sql/sql_union.cc: Name resolution context added sql/sql_update.cc: Name resolution context added sql/sql_view.cc: Name resolution context added sql/sql_view.h: table list removed from fix_fields() arguments sql/sql_yacc.yy: Name resolution context added sql/table.cc: Name resolution context added merged view processing moved sql/table.h: merged view processing moved
2005-07-01 06:05:42 +02:00
left_expr->fix_fields(thd, optimizer->arguments()));
/* fix_fields can change reference to left_expr, we need reassign it */
left_expr= optimizer->arguments()[0];
thd->lex->current_select= current;
if (result)
goto err;
/*
Both transformers call fix_fields() only for Items created inside them,
and all that items do not make permanent changes in current item arena
which allow to us call them with changed arena (if we do not know nature
of Item, we have to call fix_fields() for it only with original arena to
avoid memory leack)
*/
arena= thd->activate_stmt_arena_if_needed(&backup);
if (left_expr->cols() == 1)
trans_res= single_value_transformer(join);
else
{
/* we do not support row operation for ALL/ANY/SOME */
if (func != &eq_creator)
{
if (arena)
thd->restore_active_arena(arena, &backup);
my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
DBUG_RETURN(true);
}
trans_res= row_value_transformer(join);
}
if (arena)
thd->restore_active_arena(arena, &backup);
err:
thd->where= save_where;
DBUG_RETURN(trans_res);
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
void Item_in_subselect::print(String *str, enum_query_type query_type)
{
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
if (test_strategy(SUBS_IN_TO_EXISTS))
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN("<exists>"));
else
{
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
left_expr->print(str, query_type);
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN(" in "));
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
Item_subselect::print(str, query_type);
}
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
uint outer_cols_num;
List<Item> *inner_cols;
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
if (test_strategy(SUBS_SEMI_JOIN))
return !( (*ref)= new Item_int(1));
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
Check if the outer and inner IN operands match in those cases when we
will not perform IN=>EXISTS transformation. Currently this is when we
use subquery materialization.
The condition below is true when this method was called recursively from
inside JOIN::prepare for the JOIN object created by the call chain
Item_subselect::fix_fields -> subselect_single_select_engine::prepare,
which creates a JOIN object for the subquery and calls JOIN::prepare for
the JOIN of the subquery.
Notice that in some cases, this doesn't happen, and the check_cols()
test for each Item happens later in
Item_in_subselect::row_value_in_to_exists_transformer.
The reason for this mess is that our JOIN::prepare phase works top-down
instead of bottom-up, so we first do name resoluton and semantic checks
for the outer selects, then for the inner.
*/
if (engine &&
engine->engine_type() == subselect_engine::SINGLE_SELECT_ENGINE &&
((subselect_single_select_engine*)engine)->join)
{
outer_cols_num= left_expr->cols();
if (unit->is_union())
inner_cols= &(unit->types);
else
inner_cols= &(unit->first_select()->item_list);
if (outer_cols_num != inner_cols->elements)
{
my_error(ER_OPERAND_COLUMNS, MYF(0), outer_cols_num);
return TRUE;
}
if (outer_cols_num > 1)
{
List_iterator<Item> inner_col_it(*inner_cols);
Item *inner_col;
for (uint i= 0; i < outer_cols_num; i++)
{
inner_col= inner_col_it++;
if (inner_col->check_cols(left_expr->element_index(i)->cols()))
return TRUE;
}
}
}
Fixed following problems: --Bug#52157 various crashes and assertions with multi-table update, stored function --Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb --Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846 --Bug#57352 valgrind warnings when creating view --Recently discovered problem when a nested materialized derived table is used before being populated and it leads to incorrect result We have several modes when we should disable subquery evaluation. The reasons for disabling are different. It could be uselessness of the evaluation as in case of 'CREATE VIEW' or 'PREPARE stmt', or we should disable subquery evaluation if tables are not locked yet as it happens in bug#54475, or too early evaluation of subqueries can lead to wrong result as it happened in Bug#19077. Main problem is that if subquery items are treated as const they are evaluated in ::fix_fields(), ::fix_length_and_dec() of the parental items as a lot of these methods have Item::val_...() calls inside. We have to make subqueries non-const to prevent unnecessary subquery evaluation. At the moment we have different methods for this. Here is a list of these modes: 1. PREPARE stmt; We use UNCACHEABLE_PREPARE flag. It is set during parsing in sql_parse.cc, mysql_new_select() for each SELECT_LEX object and cleared at the end of PREPARE in sql_prepare.cc, init_stmt_after_parse(). If this flag is set subquery becomes non-const and evaluation does not happen. 2. CREATE|ALTER VIEW, SHOW CREATE VIEW, I_S tables which process FRM files We use LEX::view_prepare_mode field. We set it before view preparation and check this flag in ::fix_fields(), ::fix_length_and_dec(). Some bugs are fixed using this approach, some are not(Bug#57352, Bug#57703). The problem here is that we have a lot of ::fix_fields(), ::fix_length_and_dec() where we use Item::val_...() calls for const items. 3. Derived tables with subquery = wrong result(Bug19077) The reason of this bug is too early subquery evaluation. It was fixed by adding Item::with_subselect field The check of this field in appropriate places prevents const item evaluation if the item have subquery. The fix for Bug19077 fixes only the problem with convert_constant_item() function and does not cover other places(::fix_fields(), ::fix_length_and_dec() again) where subqueries could be evaluated. Example: CREATE TABLE t1 (i INT, j BIGINT); INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2); SELECT * FROM (SELECT MIN(i) FROM t1 WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3; DROP TABLE t1; 4. Derived tables with subquery where subquery is evaluated before table locking(Bug#54475, Bug#52157) Suggested solution is following: -Introduce new field LEX::context_analysis_only with the following possible flags: #define CONTEXT_ANALYSIS_ONLY_PREPARE 1 #define CONTEXT_ANALYSIS_ONLY_VIEW 2 #define CONTEXT_ANALYSIS_ONLY_DERIVED 4 -Set/clean these flags when we perform context analysis operation -Item_subselect::const_item() returns result depending on LEX::context_analysis_only. If context_analysis_only is set then we return FALSE that means that subquery is non-const. As all subquery types are wrapped by Item_subselect it allow as to make subquery non-const when it's necessary. mysql-test/r/derived.result: test case mysql-test/r/multi_update.result: test case mysql-test/r/view.result: test case mysql-test/suite/innodb/r/innodb_multi_update.result: test case mysql-test/suite/innodb/t/innodb_multi_update.test: test case mysql-test/suite/innodb_plugin/r/innodb_multi_update.result: test case mysql-test/suite/innodb_plugin/t/innodb_multi_update.test: test case mysql-test/t/derived.test: test case mysql-test/t/multi_update.test: test case mysql-test/t/view.test: test case sql/item.cc: --removed unnecessary code sql/item_cmpfunc.cc: --removed unnecessary checks --THD::is_context_analysis_only() is replaced with LEX::is_ps_or_view_context_analysis() sql/item_func.cc: --refactored context analysis checks sql/item_row.cc: --removed unnecessary checks sql/item_subselect.cc: --removed unnecessary code --added DBUG_ASSERT into Item_subselect::exec() which asserts that subquery execution can not happen if LEX::context_analysis_only is set, i.e. at context analysis stage. --Item_subselect::const_item() Return FALSE if LEX::context_analysis_only is set. It prevents subquery evaluation in ::fix_fields & ::fix_length_and_dec at context analysis stage. sql/item_subselect.h: --removed unnecessary code sql/mysql_priv.h: --Added new set of flags. sql/sql_class.h: --removed unnecessary code sql/sql_derived.cc: --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_lex.cc: --init LEX::context_analysis_only field sql/sql_lex.h: --New LEX::context_analysis_only field sql/sql_parse.cc: --removed unnecessary code sql/sql_prepare.cc: --removed unnecessary code --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_select.cc: --refactored context analysis checks sql/sql_show.cc: --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_view.cc: --added LEX::context_analysis_only analysis intialization/cleanup
2010-12-14 10:33:03 +01:00
if ((thd_arg->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) &&
2011-03-09 14:47:59 +01:00
left_expr && !left_expr->fixed &&
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
left_expr->fix_fields(thd_arg, &left_expr))
return TRUE;
else
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (Item_subselect::fix_fields(thd_arg, ref))
return TRUE;
fixed= TRUE;
return FALSE;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
void Item_in_subselect::fix_after_pullout(st_select_lex *new_parent, Item **ref)
{
left_expr->fix_after_pullout(new_parent, &left_expr);
Item_subselect::fix_after_pullout(new_parent, ref);
used_tables_cache |= left_expr->used_tables();
}
void Item_in_subselect::update_used_tables()
{
Item_subselect::update_used_tables();
left_expr->update_used_tables();
//used_tables_cache |= left_expr->used_tables();
used_tables_cache= Item_subselect::used_tables() | left_expr->used_tables();
}
/**
Try to create and initialize an engine to compute a subselect via
materialization.
@details
The method creates a new engine for materialized execution, and initializes
the engine. The initialization may fail
- either because it wasn't possible to create the needed temporary table
and its index,
- or because of a memory allocation error,
@returns
@retval TRUE memory allocation error occurred
@retval FALSE an execution method was chosen successfully
*/
bool Item_in_subselect::setup_mat_engine()
{
subselect_hash_sj_engine *mat_engine= NULL;
subselect_single_select_engine *select_engine;
DBUG_ENTER("Item_in_subselect::setup_mat_engine");
/*
The select_engine (that executes transformed IN=>EXISTS subselects) is
pre-created at parse time, and is stored in statment memory (preserved
across PS executions).
*/
DBUG_ASSERT(engine->engine_type() == subselect_engine::SINGLE_SELECT_ENGINE);
select_engine= (subselect_single_select_engine*) engine;
/* Create/initialize execution objects. */
if (!(mat_engine= new subselect_hash_sj_engine(thd, this, select_engine)))
DBUG_RETURN(TRUE);
2011-05-25 17:31:13 +02:00
if (mat_engine->init(&select_engine->join->fields_list,
engine->get_identifier()))
DBUG_RETURN(TRUE);
engine= mat_engine;
DBUG_RETURN(FALSE);
}
/**
Initialize the cache of the left operand of the IN predicate.
@note This method has the same purpose as alloc_group_fields(),
but it takes a different kind of collection of items, and the
list we push to is dynamically allocated.
@retval TRUE if a memory allocation error occurred or the cache is
not applicable to the current query
@retval FALSE if success
*/
bool Item_in_subselect::init_left_expr_cache()
{
JOIN *outer_join;
outer_join= unit->outer_select()->join;
/*
An IN predicate might be evaluated in a query for which all tables have
been optimzied away.
*/
if (!outer_join || !outer_join->table_count || !outer_join->tables_list)
return TRUE;
if (!(left_expr_cache= new List<Cached_item>))
return TRUE;
for (uint i= 0; i < left_expr->cols(); i++)
{
Cached_item *cur_item_cache= new_Cached_item(thd,
left_expr->element_index(i),
FALSE);
if (!cur_item_cache || left_expr_cache->push_front(cur_item_cache))
return TRUE;
}
return FALSE;
}
bool Item_in_subselect::init_cond_guards()
{
uint cols_num= left_expr->cols();
if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
{
if (!(pushed_cond_guards= (bool*)thd->alloc(sizeof(bool) * cols_num)))
return TRUE;
for (uint i= 0; i < cols_num; i++)
pushed_cond_guards[i]= TRUE;
}
return FALSE;
}
bool
Item_allany_subselect::select_transformer(JOIN *join)
{
DBUG_ENTER("Item_allany_subselect::select_transformer");
DBUG_ASSERT((in_strategy & ~(SUBS_MAXMIN_INJECTED | SUBS_MAXMIN_ENGINE |
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
SUBS_IN_TO_EXISTS | SUBS_STRATEGY_CHOSEN)) == 0);
if (upper_item)
upper_item->show= 1;
DBUG_RETURN(select_in_like_transformer(join));
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
void Item_allany_subselect::print(String *str, enum_query_type query_type)
{
Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods. ****** Fix MySQL BUG#12329653 In MariaDB, when running in ONLY_FULL_GROUP_BY mode, the server produced in incorrect error message that there is an aggregate function without GROUP BY, for artificially created MIN/MAX functions during subquery MIN/MAX optimization. The fix introduces a way to distinguish between artifially created MIN/MAX functions as a result of a rewrite, and normal ones present in the query. The test for ONLY_FULL_GROUP_BY violation now tests in addition if a MIN/MAX function was part of a MIN/MAX subquery rewrite. In order to be able to distinguish these MIN/MAX functions, the patch introduces an additional flag in Item_in_subselect::in_strategy - SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its final choice of a subuqery strategy. In order to make the choice consistent, access to Item_in_subselect::in_strategy is provided via new class methods.
2011-11-12 10:29:12 +01:00
if (test_strategy(SUBS_IN_TO_EXISTS))
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN("<exists>"));
else
{
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
left_expr->print(str, query_type);
str->append(' ');
str->append(func->symbol(all));
str->append(all ? " all " : " any ", 5);
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
Item_subselect::print(str, query_type);
}
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
void Item_allany_subselect::no_rows_in_result()
{
Fix bug lp:1008686 Analysis: The fix for bug lp:985667 implements the method Item_subselect::no_rows_in_result() for all main kinds of subqueries. The purpose of this method is to be called from return_zero_rows() and set Items to some default value in the case when a query returns no rows. Aggregates and subqueries require special treatment in this case. Every implementation of Item_subselect::no_rows_in_result() called Item_subselect::make_const() to set the subquery predicate to its default value irrespective of where the predicate was located in the query. Once the predicate was set to a constant it was never executed. At the same time, the JOIN object of the fake select for UNIONs (the one used for the final result of the UNION), was set after all subqueries in the union were executed. Since we set the subquery as constant, it was never executed, and the corresponding JOIN was never created. In order to decide whether the result of NOT IN is NULL or FALSE, Item_in_optimizer needs to check if the subquery result was empty or not. This is where we got the crash, because subselect_union_engine::no_rows() checks for unit->fake_select_lex->join->send_records, and the join object was NULL. Solution: If a subquery is in the HAVING clause it must be evaluated in order to know its result, so that we can properly filter the result records. Once subqueries in the HAVING clause are executed even in the case of no result rows, this specific crash will be solved, because the UNION will be executed, and its JOIN will be constructed. Therefore the fix for this crash is to narrow the fix for lp:985667, and to apply Item_subselect::no_rows_in_result() only when the subquery predicate is in the SELECT clause.
2012-06-15 10:33:24 +02:00
/*
Subquery predicates outside of the SELECT list must be evaluated in order
to possibly filter the special result row generated for implicit grouping
if the subquery is in the HAVING clause.
If the predicate is constant, we need its actual value in the only result
row for queries with implicit grouping.
*/
if (parsing_place != SELECT_LIST || const_item())
return;
Fix bug lp:985667, MDEV-229 Analysis: The reason for the wrong result is the interaction between constant optimization (in this case 1-row table) and subquery optimization. - First the outer query is optimized, and 'make_join_statistics' finds that table t2 has one row, reads that row, and marks the whole table as constant. This also means that all fields of t2 are constant. - Next, we optimize the subquery in the end of the outer 'make_join_statistics'. The field 'f2' is considered constant, with value '3'. The subquery predicate is rewritten as the constant TRUE. - The outer query execution detects early that the whole query result is empty and calls 'return_zero_rows'. Since the query is with implicit grouping, we have to produce one row with special values for the aggregates (depending on each aggregate function), and NULL values for all non-aggregate fields. This function calls 'no_rows_in_result' to set each aggregate function to the default value when it aggregates over an empty result, and then calls 'send_data', which in turn evaluates each Item in the SELECT list. - When evaluation reaches the subquery predicate, it executes the subquery with field 'f2' having a constant value '3', and the subquery produces the incorrect result '7'. Solution: Implement Item::no_rows_in_result for all subquery predicates. In order to make this work, it is also needed to make all val_* methods of all subquery predicates respect the Item_subselect::forced_const flag. Otherwise subqueries are executed anyways, and override the default value set by no_rows_in_result with whatever result is produced from the subquery evaluation.
2012-04-27 11:59:17 +02:00
value= 0;
null_value= 0;
was_null= 0;
make_const();
}
Clumsy but working fix for bug #11973 "SELECT .. INTO var_name; in trigger cause crash on update". Let us update "thd" pointer in LEX, all its units and in LEX::result before executing statement in trigger body, since triggers are associated with TABLE object and because of this can be used in different threads. mysql-test/r/trigger.result: Added test case for bug #11973 "SELECT .. INTO var_name; in trigger cause crash on update". mysql-test/t/trigger.test: Added test case for bug #11973 "SELECT .. INTO var_name; in trigger cause crash on update". sql/item_subselect.cc: subselect_engine: Moved implementation of set_thd() method to item_subselect.cc, since now it also sets "thd" for subselect_engine::result. sql/item_subselect.h: subselect_engine: Moved implementation of set_thd() method to item_subselect.cc, since now it also sets "thd" for subselect_engine::result. sql/sql_class.h: select_result: Added set_thd() method for updating select_result::thd value (we need this in cases when statement to which this select_result belongs will be used in different threads, as it happens for statements in trigger body). multi_delete/multi_update: Got rid of redundant "thd" member (we already have it in select_result). sql/sql_delete.cc: multi_delete: Got rid of redundant "thd" member (we already have it in select_result). sql/sql_lex.h: st_select_lex_unit: Added set_thd() method for updating st_select_lex_unit::thd value (we need this in cases when statement to which this unit belongs will be used in different threads, as it happens for statements in trigger body). We don't update thd of select_result pointed by st_select_lex_unit::result in this method, since it is either have too short lifetime (i.e. created for each execution) or is accessible via Item_subquery or LEX::result and thus already taken care of. sql/sql_parse.cc: multi_delete: Got rid of redundant "thd" member (we already have it in select_result). sql/sql_prepare.cc: reinit_stmt_before_use(): We have to update "thd" pointer in LEX, all its units and in LEX::result, since statements which belong to trigger body are associated with TABLE object and because of this can be used in different threads. sql/sql_update.cc: multi_update: Got rid of redundant "thd" member (we already have it in select_result).
2005-08-09 22:23:56 +02:00
void subselect_engine::set_thd(THD *thd_arg)
{
thd= thd_arg;
if (result)
result->set_thd(thd_arg);
}
subselect_single_select_engine::
subselect_single_select_engine(THD *thd_arg, st_select_lex *select,
select_result_interceptor *result_arg,
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
Item_subselect *item_arg)
:subselect_engine(thd_arg, item_arg, result_arg),
prepared(0), executed(0), optimize_error(0),
Preparatory (and the most problematic) patch for Bug#7306 "the server side preparedStatement error for LIMIT placeholder", which moves all uses of LIMIT clause from PREPARE to OPTIMIZE and later steps. After-review fixes. mysql-test/r/group_min_max.result: Test results fixed for EXPLAINs when using GROUP_MIN_MAX access plan. sql/item_subselect.cc: Move setting of the internal LIMIT used for IN/ALL/ANY/EXISTS subqueries to one place: Item_exists_subselect::fix_length_and_dec(). This implies that unit->select_limit_cnt is not set until the item is fixed. This is OK, as now LIMIT values are not used until JOIN::optimize. sql/mysql_priv.h: setup_tables no longer needs a special flag for the case when it's called from JOIN::reinit() (we don't need to call setup_tables between two executions of a correlated subquery). sql/opt_range.cc: Fix a glitch in GROUP_MIN_MAX access plan: we should use table metadata, not field data, to evaluate max_used_key_length, which is then used for explain. sql/sp.cc: - setup_tables signature changed. sql/sql_base.cc: - setup_tables no longer needs a special mode for subqueries. Unused checks were removed. sql/sql_delete.cc: - setup_tables signature changed sql/sql_help.cc: - setup_tables signature changed sql/sql_insert.cc: - setup_tables signature changed sql/sql_lex.cc: Consolidate setting of internal LIMIT for IN/ALL/ANY/EXISTS subqeries in one place, and hence remove it from st_select_lex::test_limit(). sql/sql_lex.h: Cleanup signature of st_select_lex_unit::init_prepare_fake_select_lex(). sql/sql_load.cc: - setup_tables signature changed sql/sql_olap.cc: - setup_tables signature changed sql/sql_parse.cc: - st_select_lex_unit::set_limit() signature changed sql/sql_select.cc: Move setting of JOIN::select_limit from JOIN::prepare to JOIN::optimize. At prepare, limit is unknown yet. Remove excessive cleanups from JOIN::reinit which were overwriting join->join_tab[i]->table->used_keys. This fixes the bug which was triggered by the change in item_subselect.cc. sql/sql_union.cc: Class st_select_lex_unit was changed to avoid calls to st_select_lex_unit::set_limit from places where it may be unknown. Now unit->select_limit_cnt is set at ::exec(). st_select_lex_unit::init_prepare_fake_select_lex(): - move out set_limit functionality - remove a few lines of dead code. st_select_lex_unit::prepare(): - now we don't call set_limit at the time of prepare, so the value of unit->select_limit_cnt may be unknown here. Use sl->select_limit instead. st_select_lex_unit::exec(): - cleanup - call set_limit explicitly as it has been moved out of init_prepare_fake_select_lex. sql/sql_update.cc: - setup_tables signature changed
2005-05-30 18:54:37 +02:00
select_lex(select), join(0)
{
Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
2006-12-14 23:51:37 +01:00
select_lex->master_unit()->item= item_arg;
}
int subselect_single_select_engine::get_identifier()
{
return select_lex->select_number;
}
void subselect_single_select_engine::cleanup()
{
DBUG_ENTER("subselect_single_select_engine::cleanup");
prepared= executed= optimize_error= 0;
join= 0;
result->cleanup();
select_lex->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
DBUG_VOID_RETURN;
}
void subselect_union_engine::cleanup()
{
DBUG_ENTER("subselect_union_engine::cleanup");
unit->reinit_exec_mechanism();
result->cleanup();
unit->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
sl->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
DBUG_VOID_RETURN;
}
bool subselect_union_engine::is_executed() const
{
return unit->executed;
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
/*
Check if last execution of the subquery engine produced any rows
SYNOPSIS
subselect_union_engine::no_rows()
DESCRIPTION
Check if last execution of the subquery engine produced any rows. The
return value is undefined if last execution ended in an error.
RETURN
TRUE - Last subselect execution has produced no rows
FALSE - Otherwise
*/
bool subselect_union_engine::no_rows()
{
/* Check if we got any rows when reading UNION result from temp. table: */
return test(!unit->fake_select_lex->join->send_records);
}
void subselect_uniquesubquery_engine::cleanup()
{
DBUG_ENTER("subselect_uniquesubquery_engine::cleanup");
DBUG_VOID_RETURN;
}
subselect_union_engine::subselect_union_engine(THD *thd_arg, st_select_lex_unit *u,
select_result_interceptor *result_arg,
Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log Docs/mysqld_error.txt: Updated error messages Makefile.am: Added missing SSL library (Should be in source distribution) configure.in: Added missing SSL library include/sql_common.h: Move duplicated prototypes innobase/os/os0file.c: Added comment for line that could be removed innobase/srv/srv0srv.c: Added comment for line that could be removed innobase/srv/srv0start.c: Added comment for line that could be removed innobase/trx/trx0sys.c: Added cast to remove compiler warning isam/isamchk.c: Fixed compiler warning libmysql/conf_to_src.c: Include files in proper order myisam/mi_check.c: Removed else part that caused compiler warning myisam/mi_delete.c: Added cast myisam/mi_page.c: Added cast myisam/mi_preload.c: Added cast myisam/mi_write.c: Added cast myisam/myisampack.c: changed 'byte' to 'current_byte' to avoid compiler warnings mysql-test/mysql-test-run.sh: Removed start-from as test '<' is not portable and this can easily be done from command line mysys/hash.c: Added cast mysys/mf_wcomp.c: Removed not reached line mysys/my_append.c: Fixed include file order to get this more portable mysys/my_copy.c: Fixed include file order to get this more portable mysys/my_redel.c: Fixed include file order to get this more portable sql-common/client.c: More DBUG_PRINT sql-common/pack.c: Added casts becasue Fortre compiler apparently compares (ulonglong) < (longlong) as signed sql/ha_heap.cc: Changed variable names to not cause hidden variables sql/ha_innodb.cc: Changed variable names to not cause hidden variables sql/item.cc: Changed variable names to not cause hidden variables sql/item.h: Changed variable names to not cause hidden variables sql/item_cmpfunc.h: Changed variable names to not cause hidden variables sql/item_func.cc: Changed variable names to not cause hidden variables sql/item_subselect.cc: Changed variable names to not cause hidden variables sql/item_subselect.h: Changed variable names to not cause hidden variables sql/item_sum.cc: Changed variable names to not cause hidden variables sql/item_timefunc.cc: Changed variable names to not cause hidden variables sql/log.cc: Changed variable names to not cause hidden variables sql/protocol.cc: Changed variable names to not cause hidden variables sql/protocol.h: Changed variable names to not cause hidden variables Remove function not declared in protocol.cc sql/protocol_cursor.cc: Changed variable names to not cause hidden variables sql/set_var.cc: Added a lot of 'version_xxx' strings Changed 'bdb_version' to 'version_bdb' sql/sql_class.cc: Changed variable names to not cause hidden variables Add TMP_TABLE_PARAM::init() to allow one to initialize structure several times sql/sql_class.h: Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) sql/sql_derived.cc: Avoid copying TMP_TABLE_PARAM (Use class version instead) sql/sql_error.cc: More DBUG sql/sql_help.cc: Fixed compiler warning sql/sql_lex.cc: Changed variable names to not cause hidden variables sql/sql_list.h: Changed variable names to not cause hidden variables sql/sql_parse.cc: Changed variable names to not cause hidden variables sql/sql_select.cc: Changed variable names to not cause hidden variables Ensure that you don't send NULL to printf() for %s Fixed problem with printing sub selects to debug log sql/sql_select.h: Changed variable names to not cause hidden variables sql/sql_union.cc: Changed variable names to not cause hidden variables Don't use local copy of TMP_TABLE_PARAM (Caused core dump on Solaris) sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Remove warning strings/conf_to_src.c: Fixed include file order
2003-11-28 11:18:13 +01:00
Item_subselect *item_arg)
:subselect_engine(thd_arg, item_arg, result_arg)
{
unit= u;
Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log Docs/mysqld_error.txt: Updated error messages Makefile.am: Added missing SSL library (Should be in source distribution) configure.in: Added missing SSL library include/sql_common.h: Move duplicated prototypes innobase/os/os0file.c: Added comment for line that could be removed innobase/srv/srv0srv.c: Added comment for line that could be removed innobase/srv/srv0start.c: Added comment for line that could be removed innobase/trx/trx0sys.c: Added cast to remove compiler warning isam/isamchk.c: Fixed compiler warning libmysql/conf_to_src.c: Include files in proper order myisam/mi_check.c: Removed else part that caused compiler warning myisam/mi_delete.c: Added cast myisam/mi_page.c: Added cast myisam/mi_preload.c: Added cast myisam/mi_write.c: Added cast myisam/myisampack.c: changed 'byte' to 'current_byte' to avoid compiler warnings mysql-test/mysql-test-run.sh: Removed start-from as test '<' is not portable and this can easily be done from command line mysys/hash.c: Added cast mysys/mf_wcomp.c: Removed not reached line mysys/my_append.c: Fixed include file order to get this more portable mysys/my_copy.c: Fixed include file order to get this more portable mysys/my_redel.c: Fixed include file order to get this more portable sql-common/client.c: More DBUG_PRINT sql-common/pack.c: Added casts becasue Fortre compiler apparently compares (ulonglong) < (longlong) as signed sql/ha_heap.cc: Changed variable names to not cause hidden variables sql/ha_innodb.cc: Changed variable names to not cause hidden variables sql/item.cc: Changed variable names to not cause hidden variables sql/item.h: Changed variable names to not cause hidden variables sql/item_cmpfunc.h: Changed variable names to not cause hidden variables sql/item_func.cc: Changed variable names to not cause hidden variables sql/item_subselect.cc: Changed variable names to not cause hidden variables sql/item_subselect.h: Changed variable names to not cause hidden variables sql/item_sum.cc: Changed variable names to not cause hidden variables sql/item_timefunc.cc: Changed variable names to not cause hidden variables sql/log.cc: Changed variable names to not cause hidden variables sql/protocol.cc: Changed variable names to not cause hidden variables sql/protocol.h: Changed variable names to not cause hidden variables Remove function not declared in protocol.cc sql/protocol_cursor.cc: Changed variable names to not cause hidden variables sql/set_var.cc: Added a lot of 'version_xxx' strings Changed 'bdb_version' to 'version_bdb' sql/sql_class.cc: Changed variable names to not cause hidden variables Add TMP_TABLE_PARAM::init() to allow one to initialize structure several times sql/sql_class.h: Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) sql/sql_derived.cc: Avoid copying TMP_TABLE_PARAM (Use class version instead) sql/sql_error.cc: More DBUG sql/sql_help.cc: Fixed compiler warning sql/sql_lex.cc: Changed variable names to not cause hidden variables sql/sql_list.h: Changed variable names to not cause hidden variables sql/sql_parse.cc: Changed variable names to not cause hidden variables sql/sql_select.cc: Changed variable names to not cause hidden variables Ensure that you don't send NULL to printf() for %s Fixed problem with printing sub selects to debug log sql/sql_select.h: Changed variable names to not cause hidden variables sql/sql_union.cc: Changed variable names to not cause hidden variables Don't use local copy of TMP_TABLE_PARAM (Caused core dump on Solaris) sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Remove warning strings/conf_to_src.c: Fixed include file order
2003-11-28 11:18:13 +01:00
if (!result_arg) //out of memory
current_thd->fatal_error();
Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log Docs/mysqld_error.txt: Updated error messages Makefile.am: Added missing SSL library (Should be in source distribution) configure.in: Added missing SSL library include/sql_common.h: Move duplicated prototypes innobase/os/os0file.c: Added comment for line that could be removed innobase/srv/srv0srv.c: Added comment for line that could be removed innobase/srv/srv0start.c: Added comment for line that could be removed innobase/trx/trx0sys.c: Added cast to remove compiler warning isam/isamchk.c: Fixed compiler warning libmysql/conf_to_src.c: Include files in proper order myisam/mi_check.c: Removed else part that caused compiler warning myisam/mi_delete.c: Added cast myisam/mi_page.c: Added cast myisam/mi_preload.c: Added cast myisam/mi_write.c: Added cast myisam/myisampack.c: changed 'byte' to 'current_byte' to avoid compiler warnings mysql-test/mysql-test-run.sh: Removed start-from as test '<' is not portable and this can easily be done from command line mysys/hash.c: Added cast mysys/mf_wcomp.c: Removed not reached line mysys/my_append.c: Fixed include file order to get this more portable mysys/my_copy.c: Fixed include file order to get this more portable mysys/my_redel.c: Fixed include file order to get this more portable sql-common/client.c: More DBUG_PRINT sql-common/pack.c: Added casts becasue Fortre compiler apparently compares (ulonglong) < (longlong) as signed sql/ha_heap.cc: Changed variable names to not cause hidden variables sql/ha_innodb.cc: Changed variable names to not cause hidden variables sql/item.cc: Changed variable names to not cause hidden variables sql/item.h: Changed variable names to not cause hidden variables sql/item_cmpfunc.h: Changed variable names to not cause hidden variables sql/item_func.cc: Changed variable names to not cause hidden variables sql/item_subselect.cc: Changed variable names to not cause hidden variables sql/item_subselect.h: Changed variable names to not cause hidden variables sql/item_sum.cc: Changed variable names to not cause hidden variables sql/item_timefunc.cc: Changed variable names to not cause hidden variables sql/log.cc: Changed variable names to not cause hidden variables sql/protocol.cc: Changed variable names to not cause hidden variables sql/protocol.h: Changed variable names to not cause hidden variables Remove function not declared in protocol.cc sql/protocol_cursor.cc: Changed variable names to not cause hidden variables sql/set_var.cc: Added a lot of 'version_xxx' strings Changed 'bdb_version' to 'version_bdb' sql/sql_class.cc: Changed variable names to not cause hidden variables Add TMP_TABLE_PARAM::init() to allow one to initialize structure several times sql/sql_class.h: Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) sql/sql_derived.cc: Avoid copying TMP_TABLE_PARAM (Use class version instead) sql/sql_error.cc: More DBUG sql/sql_help.cc: Fixed compiler warning sql/sql_lex.cc: Changed variable names to not cause hidden variables sql/sql_list.h: Changed variable names to not cause hidden variables sql/sql_parse.cc: Changed variable names to not cause hidden variables sql/sql_select.cc: Changed variable names to not cause hidden variables Ensure that you don't send NULL to printf() for %s Fixed problem with printing sub selects to debug log sql/sql_select.h: Changed variable names to not cause hidden variables sql/sql_union.cc: Changed variable names to not cause hidden variables Don't use local copy of TMP_TABLE_PARAM (Caused core dump on Solaris) sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Remove warning strings/conf_to_src.c: Fixed include file order
2003-11-28 11:18:13 +01:00
unit->item= item_arg;
}
Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log Docs/mysqld_error.txt: Updated error messages Makefile.am: Added missing SSL library (Should be in source distribution) configure.in: Added missing SSL library include/sql_common.h: Move duplicated prototypes innobase/os/os0file.c: Added comment for line that could be removed innobase/srv/srv0srv.c: Added comment for line that could be removed innobase/srv/srv0start.c: Added comment for line that could be removed innobase/trx/trx0sys.c: Added cast to remove compiler warning isam/isamchk.c: Fixed compiler warning libmysql/conf_to_src.c: Include files in proper order myisam/mi_check.c: Removed else part that caused compiler warning myisam/mi_delete.c: Added cast myisam/mi_page.c: Added cast myisam/mi_preload.c: Added cast myisam/mi_write.c: Added cast myisam/myisampack.c: changed 'byte' to 'current_byte' to avoid compiler warnings mysql-test/mysql-test-run.sh: Removed start-from as test '<' is not portable and this can easily be done from command line mysys/hash.c: Added cast mysys/mf_wcomp.c: Removed not reached line mysys/my_append.c: Fixed include file order to get this more portable mysys/my_copy.c: Fixed include file order to get this more portable mysys/my_redel.c: Fixed include file order to get this more portable sql-common/client.c: More DBUG_PRINT sql-common/pack.c: Added casts becasue Fortre compiler apparently compares (ulonglong) < (longlong) as signed sql/ha_heap.cc: Changed variable names to not cause hidden variables sql/ha_innodb.cc: Changed variable names to not cause hidden variables sql/item.cc: Changed variable names to not cause hidden variables sql/item.h: Changed variable names to not cause hidden variables sql/item_cmpfunc.h: Changed variable names to not cause hidden variables sql/item_func.cc: Changed variable names to not cause hidden variables sql/item_subselect.cc: Changed variable names to not cause hidden variables sql/item_subselect.h: Changed variable names to not cause hidden variables sql/item_sum.cc: Changed variable names to not cause hidden variables sql/item_timefunc.cc: Changed variable names to not cause hidden variables sql/log.cc: Changed variable names to not cause hidden variables sql/protocol.cc: Changed variable names to not cause hidden variables sql/protocol.h: Changed variable names to not cause hidden variables Remove function not declared in protocol.cc sql/protocol_cursor.cc: Changed variable names to not cause hidden variables sql/set_var.cc: Added a lot of 'version_xxx' strings Changed 'bdb_version' to 'version_bdb' sql/sql_class.cc: Changed variable names to not cause hidden variables Add TMP_TABLE_PARAM::init() to allow one to initialize structure several times sql/sql_class.h: Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) sql/sql_derived.cc: Avoid copying TMP_TABLE_PARAM (Use class version instead) sql/sql_error.cc: More DBUG sql/sql_help.cc: Fixed compiler warning sql/sql_lex.cc: Changed variable names to not cause hidden variables sql/sql_list.h: Changed variable names to not cause hidden variables sql/sql_parse.cc: Changed variable names to not cause hidden variables sql/sql_select.cc: Changed variable names to not cause hidden variables Ensure that you don't send NULL to printf() for %s Fixed problem with printing sub selects to debug log sql/sql_select.h: Changed variable names to not cause hidden variables sql/sql_union.cc: Changed variable names to not cause hidden variables Don't use local copy of TMP_TABLE_PARAM (Caused core dump on Solaris) sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Remove warning strings/conf_to_src.c: Fixed include file order
2003-11-28 11:18:13 +01:00
/**
Create and prepare the JOIN object that represents the query execution
plan for the subquery.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
@details
This method is called from Item_subselect::fix_fields. For prepared
statements it is called both during the PREPARE and EXECUTE phases in the
following ways:
- During PREPARE the optimizer needs some properties
(join->fields_list.elements) of the JOIN to proceed with preparation of
the remaining query (namely to complete ::fix_fields for the subselect
related classes. In the end of PREPARE the JOIN is deleted.
- When we EXECUTE the query, Item_subselect::fix_fields is called again, and
the JOIN object is re-created again, prepared and executed. In the end of
execution it is deleted.
In all cases the JOIN is created in runtime memory (not in the permanent
memory root).
@todo
Re-check what properties of 'join' are needed during prepare, and see if
we can avoid creating a JOIN during JOIN::prepare of the outer join.
@retval 0 if success
@retval 1 if error
*/
int subselect_single_select_engine::prepare()
{
if (prepared)
return 0;
if (select_lex->join)
{
select_lex->cleanup();
}
join= new JOIN(thd, select_lex->item_list,
select_lex->options | SELECT_NO_UNLOCK, result);
if (!join || !result)
{
Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log Docs/mysqld_error.txt: Updated error messages Makefile.am: Added missing SSL library (Should be in source distribution) configure.in: Added missing SSL library include/sql_common.h: Move duplicated prototypes innobase/os/os0file.c: Added comment for line that could be removed innobase/srv/srv0srv.c: Added comment for line that could be removed innobase/srv/srv0start.c: Added comment for line that could be removed innobase/trx/trx0sys.c: Added cast to remove compiler warning isam/isamchk.c: Fixed compiler warning libmysql/conf_to_src.c: Include files in proper order myisam/mi_check.c: Removed else part that caused compiler warning myisam/mi_delete.c: Added cast myisam/mi_page.c: Added cast myisam/mi_preload.c: Added cast myisam/mi_write.c: Added cast myisam/myisampack.c: changed 'byte' to 'current_byte' to avoid compiler warnings mysql-test/mysql-test-run.sh: Removed start-from as test '<' is not portable and this can easily be done from command line mysys/hash.c: Added cast mysys/mf_wcomp.c: Removed not reached line mysys/my_append.c: Fixed include file order to get this more portable mysys/my_copy.c: Fixed include file order to get this more portable mysys/my_redel.c: Fixed include file order to get this more portable sql-common/client.c: More DBUG_PRINT sql-common/pack.c: Added casts becasue Fortre compiler apparently compares (ulonglong) < (longlong) as signed sql/ha_heap.cc: Changed variable names to not cause hidden variables sql/ha_innodb.cc: Changed variable names to not cause hidden variables sql/item.cc: Changed variable names to not cause hidden variables sql/item.h: Changed variable names to not cause hidden variables sql/item_cmpfunc.h: Changed variable names to not cause hidden variables sql/item_func.cc: Changed variable names to not cause hidden variables sql/item_subselect.cc: Changed variable names to not cause hidden variables sql/item_subselect.h: Changed variable names to not cause hidden variables sql/item_sum.cc: Changed variable names to not cause hidden variables sql/item_timefunc.cc: Changed variable names to not cause hidden variables sql/log.cc: Changed variable names to not cause hidden variables sql/protocol.cc: Changed variable names to not cause hidden variables sql/protocol.h: Changed variable names to not cause hidden variables Remove function not declared in protocol.cc sql/protocol_cursor.cc: Changed variable names to not cause hidden variables sql/set_var.cc: Added a lot of 'version_xxx' strings Changed 'bdb_version' to 'version_bdb' sql/sql_class.cc: Changed variable names to not cause hidden variables Add TMP_TABLE_PARAM::init() to allow one to initialize structure several times sql/sql_class.h: Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) sql/sql_derived.cc: Avoid copying TMP_TABLE_PARAM (Use class version instead) sql/sql_error.cc: More DBUG sql/sql_help.cc: Fixed compiler warning sql/sql_lex.cc: Changed variable names to not cause hidden variables sql/sql_list.h: Changed variable names to not cause hidden variables sql/sql_parse.cc: Changed variable names to not cause hidden variables sql/sql_select.cc: Changed variable names to not cause hidden variables Ensure that you don't send NULL to printf() for %s Fixed problem with printing sub selects to debug log sql/sql_select.h: Changed variable names to not cause hidden variables sql/sql_union.cc: Changed variable names to not cause hidden variables Don't use local copy of TMP_TABLE_PARAM (Caused core dump on Solaris) sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Remove warning strings/conf_to_src.c: Fixed include file order
2003-11-28 11:18:13 +01:00
thd->fatal_error(); //out of memory
return 1;
}
prepared= 1;
THD::lex now points to THD::main_lex like in 5.0 All tests pass (client_test included) libmysqld/lib_sql.cc: THD::lex now points to THD::main_lex like in 5.0 sql/filesort.cc: THD::lex now points to THD::main_lex like in 5.0 sql/ha_innodb.cc: THD::lex now points to THD::main_lex like in 5.0 sql/ha_myisam.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_cmpfunc.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_create.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_func.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_subselect.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_sum.cc: THD::lex now points to THD::main_lex like in 5.0 sql/mysql_priv.h: THD::lex now points to THD::main_lex like in 5.0 sql/mysqld.cc: THD::lex now points to THD::main_lex like in 5.0 sql/protocol.cc: THD::lex now points to THD::main_lex like in 5.0 sql/repl_failsafe.cc: THD::lex now points to THD::main_lex like in 5.0 sql/slave.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_acl.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_base.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_cache.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_class.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_class.h: THD::lex now points to THD::main_lex like in 5.0 sql/sql_delete.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_error.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_insert.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_lex.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_lex.h: THD::lex now points to THD::main_lex like in 5.0 sql/sql_parse.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_prepare.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_repl.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_select.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_table.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_union.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_update.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_yacc.yy: THD::lex now points to THD::main_lex like in 5.0
2003-12-19 18:52:13 +01:00
SELECT_LEX *save_select= thd->lex->current_select;
thd->lex->current_select= select_lex;
if (join->prepare(&select_lex->ref_pointer_array,
Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. One somewhat major source of strict-aliasing violations and related warnings is the SQL_LIST structure. For example, consider its member function `link_in_list` which takes a pointer to pointer of type T (any type) as a pointer to pointer to unsigned char. Dereferencing this pointer, which is done to reset the next field, violates strict-aliasing rules and might cause problems for surrounding code that uses the next field of the object being added to the list. The solution is to use templates to parametrize the SQL_LIST structure in order to deference the pointers with compatible types. As a side bonus, it becomes possible to remove quite a few casts related to acessing data members of SQL_LIST. sql/handler.h: Use the appropriate template type argument. sql/item.cc: Remove now-unnecessary cast. sql/item_subselect.cc: Remove now-unnecessary casts. sql/item_sum.cc: Use the appropriate template type argument. Remove now-unnecessary cast. sql/mysql_priv.h: Move SQL_LIST structure to sql_list.h Use the appropriate template type argument. sql/sp.cc: Remove now-unnecessary casts. sql/sql_delete.cc: Use the appropriate template type argument. Remove now-unnecessary casts. sql/sql_derived.cc: Remove now-unnecessary casts. sql/sql_lex.cc: Remove now-unnecessary casts. sql/sql_lex.h: SQL_LIST now takes a template type argument which must match the type of the elements of the list. Use forward declaration when the type is not available, it is used in pointers anyway. sql/sql_list.h: Rename SQL_LIST to SQL_I_List. The template parameter is the type of object that is stored in the list. sql/sql_olap.cc: Remove now-unnecessary casts. sql/sql_parse.cc: Remove now-unnecessary casts. sql/sql_prepare.cc: Remove now-unnecessary casts. sql/sql_select.cc: Remove now-unnecessary casts. sql/sql_show.cc: Remove now-unnecessary casts. sql/sql_table.cc: Remove now-unnecessary casts. sql/sql_trigger.cc: Remove now-unnecessary casts. sql/sql_union.cc: Remove now-unnecessary casts. sql/sql_update.cc: Remove now-unnecessary casts. sql/sql_view.cc: Remove now-unnecessary casts. sql/sql_yacc.yy: Remove now-unnecessary casts. storage/myisammrg/ha_myisammrg.cc: Remove now-unnecessary casts.
2010-06-10 22:45:22 +02:00
select_lex->table_list.first,
select_lex->with_wild,
select_lex->where,
select_lex->order_list.elements +
select_lex->group_list.elements,
Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. One somewhat major source of strict-aliasing violations and related warnings is the SQL_LIST structure. For example, consider its member function `link_in_list` which takes a pointer to pointer of type T (any type) as a pointer to pointer to unsigned char. Dereferencing this pointer, which is done to reset the next field, violates strict-aliasing rules and might cause problems for surrounding code that uses the next field of the object being added to the list. The solution is to use templates to parametrize the SQL_LIST structure in order to deference the pointers with compatible types. As a side bonus, it becomes possible to remove quite a few casts related to acessing data members of SQL_LIST. sql/handler.h: Use the appropriate template type argument. sql/item.cc: Remove now-unnecessary cast. sql/item_subselect.cc: Remove now-unnecessary casts. sql/item_sum.cc: Use the appropriate template type argument. Remove now-unnecessary cast. sql/mysql_priv.h: Move SQL_LIST structure to sql_list.h Use the appropriate template type argument. sql/sp.cc: Remove now-unnecessary casts. sql/sql_delete.cc: Use the appropriate template type argument. Remove now-unnecessary casts. sql/sql_derived.cc: Remove now-unnecessary casts. sql/sql_lex.cc: Remove now-unnecessary casts. sql/sql_lex.h: SQL_LIST now takes a template type argument which must match the type of the elements of the list. Use forward declaration when the type is not available, it is used in pointers anyway. sql/sql_list.h: Rename SQL_LIST to SQL_I_List. The template parameter is the type of object that is stored in the list. sql/sql_olap.cc: Remove now-unnecessary casts. sql/sql_parse.cc: Remove now-unnecessary casts. sql/sql_prepare.cc: Remove now-unnecessary casts. sql/sql_select.cc: Remove now-unnecessary casts. sql/sql_show.cc: Remove now-unnecessary casts. sql/sql_table.cc: Remove now-unnecessary casts. sql/sql_trigger.cc: Remove now-unnecessary casts. sql/sql_union.cc: Remove now-unnecessary casts. sql/sql_update.cc: Remove now-unnecessary casts. sql/sql_view.cc: Remove now-unnecessary casts. sql/sql_yacc.yy: Remove now-unnecessary casts. storage/myisammrg/ha_myisammrg.cc: Remove now-unnecessary casts.
2010-06-10 22:45:22 +02:00
select_lex->order_list.first,
select_lex->group_list.first,
select_lex->having,
Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. One somewhat major source of strict-aliasing violations and related warnings is the SQL_LIST structure. For example, consider its member function `link_in_list` which takes a pointer to pointer of type T (any type) as a pointer to pointer to unsigned char. Dereferencing this pointer, which is done to reset the next field, violates strict-aliasing rules and might cause problems for surrounding code that uses the next field of the object being added to the list. The solution is to use templates to parametrize the SQL_LIST structure in order to deference the pointers with compatible types. As a side bonus, it becomes possible to remove quite a few casts related to acessing data members of SQL_LIST. sql/handler.h: Use the appropriate template type argument. sql/item.cc: Remove now-unnecessary cast. sql/item_subselect.cc: Remove now-unnecessary casts. sql/item_sum.cc: Use the appropriate template type argument. Remove now-unnecessary cast. sql/mysql_priv.h: Move SQL_LIST structure to sql_list.h Use the appropriate template type argument. sql/sp.cc: Remove now-unnecessary casts. sql/sql_delete.cc: Use the appropriate template type argument. Remove now-unnecessary casts. sql/sql_derived.cc: Remove now-unnecessary casts. sql/sql_lex.cc: Remove now-unnecessary casts. sql/sql_lex.h: SQL_LIST now takes a template type argument which must match the type of the elements of the list. Use forward declaration when the type is not available, it is used in pointers anyway. sql/sql_list.h: Rename SQL_LIST to SQL_I_List. The template parameter is the type of object that is stored in the list. sql/sql_olap.cc: Remove now-unnecessary casts. sql/sql_parse.cc: Remove now-unnecessary casts. sql/sql_prepare.cc: Remove now-unnecessary casts. sql/sql_select.cc: Remove now-unnecessary casts. sql/sql_show.cc: Remove now-unnecessary casts. sql/sql_table.cc: Remove now-unnecessary casts. sql/sql_trigger.cc: Remove now-unnecessary casts. sql/sql_union.cc: Remove now-unnecessary casts. sql/sql_update.cc: Remove now-unnecessary casts. sql/sql_view.cc: Remove now-unnecessary casts. sql/sql_yacc.yy: Remove now-unnecessary casts. storage/myisammrg/ha_myisammrg.cc: Remove now-unnecessary casts.
2010-06-10 22:45:22 +02:00
NULL, select_lex,
Fixed UNION fields type/length detecting mysql-test/r/union.result: new results with max union field length detecting type conversion tests mysql-test/t/union.test: type conversion tests sql/field.h: field converion support sql/item.cc: fixed printing field of internal temporary table of SELECT (reference from HAVING clause) layout fix new item for storing field type sql/item.h: new item for storing field type sql/item_subselect.cc: new subquery item length/dec detecting sql/mysql_priv.h: we do not need pre-inited tables and fields sql/sql_base.cc: we do not need double fix_fielding sql/sql_class.h: we do not need double fix_fielding sql/sql_derived.cc: preparing moved before temporary table creation sql/sql_lex.h: we do not need pre-inited tables and fields new lists to store fields types and fields of temporary table sql/sql_parse.cc: we do not need pre-inited tables and fields sql/sql_prepare.cc: we do not need pre-inited tables and fields sql/sql_select.cc: we do not need pre-inited tables and fields support mysql_select call from derived tables after it preparing (in derived table routing) support of crreating temporary table fields from Item_type_holder sql/sql_select.h: we do not need pre-inited tables and fields sql/sql_union.cc: we do not need pre-inited tables and fields check of columns number in union moved to prepare() prepering of SELECTS moved before temporary table creation, fixed union columns type/length detecting sql/sql_update.cc: we do not need pre-inited tables and fields
2003-11-23 01:01:15 +01:00
select_lex->master_unit()))
return 1;
THD::lex now points to THD::main_lex like in 5.0 All tests pass (client_test included) libmysqld/lib_sql.cc: THD::lex now points to THD::main_lex like in 5.0 sql/filesort.cc: THD::lex now points to THD::main_lex like in 5.0 sql/ha_innodb.cc: THD::lex now points to THD::main_lex like in 5.0 sql/ha_myisam.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_cmpfunc.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_create.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_func.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_subselect.cc: THD::lex now points to THD::main_lex like in 5.0 sql/item_sum.cc: THD::lex now points to THD::main_lex like in 5.0 sql/mysql_priv.h: THD::lex now points to THD::main_lex like in 5.0 sql/mysqld.cc: THD::lex now points to THD::main_lex like in 5.0 sql/protocol.cc: THD::lex now points to THD::main_lex like in 5.0 sql/repl_failsafe.cc: THD::lex now points to THD::main_lex like in 5.0 sql/slave.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_acl.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_base.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_cache.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_class.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_class.h: THD::lex now points to THD::main_lex like in 5.0 sql/sql_delete.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_error.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_insert.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_lex.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_lex.h: THD::lex now points to THD::main_lex like in 5.0 sql/sql_parse.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_prepare.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_repl.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_select.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_table.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_union.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_update.cc: THD::lex now points to THD::main_lex like in 5.0 sql/sql_yacc.yy: THD::lex now points to THD::main_lex like in 5.0
2003-12-19 18:52:13 +01:00
thd->lex->current_select= save_select;
return 0;
}
int subselect_union_engine::prepare()
{
A fix and a test case for Bug#6513 "Test Suite: Values inserted by using cursor is interpreted latin1 character and Bug#9819 "Cursors: Mysql Server Crash while fetching from table with 5 million records." A fix for a possible memory leak when fetching into an SP cursor in a long loop. The patch uses a common implementation of cursors in the binary protocol and in stored procedures and implements materialized cursors. For implementation details, see comments in sql_cursor.cc include/my_sys.h: - declaration for multi_alloc_root libmysqld/Makefile.am: - drop protocol_cursor.cc, add sql_cursor.cc (replaces the old implementation of cursors with a new one) mysql-test/r/ctype_ujis.result: - test results fixed (a test case for Bug#6513) mysql-test/r/sp-big.result: - test results fixed (a test case for Bug#9819) mysql-test/t/ctype_ujis.test: Add a test case for Bug#6513 "Test Suite: Values inserted by using cursor is interpreted latin1 character" mysql-test/t/sp-big.test: Add a restricted test case for Bug#9819 "Cursors: Mysql Server Crash while fetching from table with 5 million records." mysys/my_alloc.c: - an implementation of multi_alloc_root; this is largely a copy-paste from mulalloc.c, but the function is small and there is no easy way to reuse the existing C function. sql/Makefile.am: - add sql_cursor.h, sql_cursor.cc (a new implementation of stored procedure cursors) and drop protocol_cursor.cc (the old one) sql/handler.cc: - now TABLE object has its mem_root always initialized. Adjust the implementation handler::ha_open sql/item_subselect.cc: - adjust to the changed declaration of st_select_lex_unit::prepare sql/protocol.h: - drop Protocol_cursor sql/sp_head.cc: - move juggling with Query_arena::free_list and Item::next to sp_eval_func_item, as this is needed in 3 places already. sql/sp_head.h: - declare a no-op implementation for cleanup_stmt in sp_instr_cpush. This method is needed for non-materializing cursors, which are yet not used in stored procedures. - declaration for sp_eval_func_item sql/sp_rcontext.cc: - reimplement sp_cursor using the new implementation of server side cursors. - use sp_eval_func_item to assign values of SP variables from the row fetched from a cursor. This should fix a possible memory leak in the old implementation of sp_cursor::fetch sql/sp_rcontext.h: - reimplement sp_cursor using the new implementation of server side cursors. sql/sql_class.cc: - disable the functionality that closes transient cursors at commit/rollback; transient cursors are not used in 5.0, instead we use materialized ones. To be enabled in a later version. sql/sql_class.h: - adjust to the rename Cursor -> Server_side_cursor - additional declarations of select_union used in materialized cursors sql/sql_derived.cc: - reuse bits of tmp table code in UNION, derived tables, and materialized cursors - cleanup comments sql/sql_lex.h: - declarations of auxiliary methods used by materialized cursors - a cleanup in st_select_lex_unit interface sql/sql_list.h: - add an array operator new[] to class Sql_alloc sql/sql_prepare.cc: - split the tight coupling of cursors and prepared statements to reuse the same implementation in stored procedures - cleanups of error processing in Prepared_statement::{prepare,execute} sql/sql_select.cc: - move the implementation of sensitive (non-materializing) cursors to sql_cursor.cc - make temporary tables self-contained: the table, its record and fields are allocated in TABLE::mem_root. This implementation is not clean and resets thd->mem_root several times because of the way create_tmp_table works (many additional things are done inside it). - adjust to the changed declaration of st_select_lex_unit::prepare sql/sql_select.h: - move the declaration of sensitive (non-materializing) cursors to sql_cursor.cc sql/sql_union.cc: - move pieces of st_select_unit::prepare to select_union and st_table methods to be able to reuse code in the implementation of materialized cursors sql/sql_view.cc: - adjust to the changed signature of st_select_lex_unit::prepare sql/table.cc: - implement auxiliary st_table methods for use with temporary tables sql/table.h: - add declarations for auxiliary methods of st_table used to work with temporary tables tests/mysql_client_test.c: - if cursors are materialized, a parallel update of the table used in the cursor may go through: update the test. sql/sql_cursor.cc: New BitKeeper file ``sql/sql_cursor.cc'' -- implementation of server side cursors sql/sql_cursor.h: New BitKeeper file ``sql/sql_cursor.h'' - declarations for server side cursors.
2005-09-22 00:11:21 +02:00
return unit->prepare(thd, result, SELECT_NO_UNLOCK);
}
int subselect_uniquesubquery_engine::prepare()
{
/* Should never be called. */
DBUG_ASSERT(FALSE);
return 1;
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
/*
Check if last execution of the subquery engine produced any rows
SYNOPSIS
subselect_single_select_engine::no_rows()
DESCRIPTION
Check if last execution of the subquery engine produced any rows. The
return value is undefined if last execution ended in an error.
RETURN
TRUE - Last subselect execution has produced no rows
FALSE - Otherwise
*/
bool subselect_single_select_engine::no_rows()
{
return !item->assigned();
}
/*
makes storage for the output values for the subquery and calcuates
their data and column types and their nullability.
*/
void subselect_engine::set_row(List<Item> &item_list, Item_cache **row)
{
Item *sel_item;
Fixed UNION fields type/length detecting mysql-test/r/union.result: new results with max union field length detecting type conversion tests mysql-test/t/union.test: type conversion tests sql/field.h: field converion support sql/item.cc: fixed printing field of internal temporary table of SELECT (reference from HAVING clause) layout fix new item for storing field type sql/item.h: new item for storing field type sql/item_subselect.cc: new subquery item length/dec detecting sql/mysql_priv.h: we do not need pre-inited tables and fields sql/sql_base.cc: we do not need double fix_fielding sql/sql_class.h: we do not need double fix_fielding sql/sql_derived.cc: preparing moved before temporary table creation sql/sql_lex.h: we do not need pre-inited tables and fields new lists to store fields types and fields of temporary table sql/sql_parse.cc: we do not need pre-inited tables and fields sql/sql_prepare.cc: we do not need pre-inited tables and fields sql/sql_select.cc: we do not need pre-inited tables and fields support mysql_select call from derived tables after it preparing (in derived table routing) support of crreating temporary table fields from Item_type_holder sql/sql_select.h: we do not need pre-inited tables and fields sql/sql_union.cc: we do not need pre-inited tables and fields check of columns number in union moved to prepare() prepering of SELECTS moved before temporary table creation, fixed union columns type/length detecting sql/sql_update.cc: we do not need pre-inited tables and fields
2003-11-23 01:01:15 +01:00
List_iterator_fast<Item> li(item_list);
res_type= STRING_RESULT;
res_field_type= MYSQL_TYPE_VAR_STRING;
for (uint i= 0; (sel_item= li++); i++)
{
item->max_length= sel_item->max_length;
res_type= sel_item->result_type();
res_field_type= sel_item->field_type();
item->decimals= sel_item->decimals;
item->unsigned_flag= sel_item->unsigned_flag;
maybe_null= sel_item->maybe_null;
if (!(row[i]= Item_cache::get_cache(sel_item, sel_item->cmp_type())))
return;
row[i]->setup(sel_item);
//psergey-backport-timours: row[i]->store(sel_item);
}
Fixed UNION fields type/length detecting mysql-test/r/union.result: new results with max union field length detecting type conversion tests mysql-test/t/union.test: type conversion tests sql/field.h: field converion support sql/item.cc: fixed printing field of internal temporary table of SELECT (reference from HAVING clause) layout fix new item for storing field type sql/item.h: new item for storing field type sql/item_subselect.cc: new subquery item length/dec detecting sql/mysql_priv.h: we do not need pre-inited tables and fields sql/sql_base.cc: we do not need double fix_fielding sql/sql_class.h: we do not need double fix_fielding sql/sql_derived.cc: preparing moved before temporary table creation sql/sql_lex.h: we do not need pre-inited tables and fields new lists to store fields types and fields of temporary table sql/sql_parse.cc: we do not need pre-inited tables and fields sql/sql_prepare.cc: we do not need pre-inited tables and fields sql/sql_select.cc: we do not need pre-inited tables and fields support mysql_select call from derived tables after it preparing (in derived table routing) support of crreating temporary table fields from Item_type_holder sql/sql_select.h: we do not need pre-inited tables and fields sql/sql_union.cc: we do not need pre-inited tables and fields check of columns number in union moved to prepare() prepering of SELECTS moved before temporary table creation, fixed union columns type/length detecting sql/sql_update.cc: we do not need pre-inited tables and fields
2003-11-23 01:01:15 +01:00
if (item_list.elements > 1)
res_type= ROW_RESULT;
}
void subselect_single_select_engine::fix_length_and_dec(Item_cache **row)
{
DBUG_ASSERT(row || select_lex->item_list.elements==1);
set_row(select_lex->item_list, row);
item->collation.set(row[0]->collation);
2002-12-27 20:19:25 +01:00
if (cols() != 1)
maybe_null= 0;
}
void subselect_union_engine::fix_length_and_dec(Item_cache **row)
{
DBUG_ASSERT(row || unit->first_select()->item_list.elements==1);
if (unit->first_select()->item_list.elements == 1)
{
set_row(unit->types, row);
item->collation.set(row[0]->collation);
}
else
{
bool maybe_null_saved= maybe_null;
set_row(unit->types, row);
maybe_null= maybe_null_saved;
}
}
void subselect_uniquesubquery_engine::fix_length_and_dec(Item_cache **row)
{
//this never should be called
DBUG_ASSERT(0);
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
int init_read_record_seq(JOIN_TAB *tab);
int join_read_always_key_or_null(JOIN_TAB *tab);
int join_read_next_same_or_null(READ_RECORD *info);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
int subselect_single_select_engine::exec()
{
DBUG_ENTER("subselect_single_select_engine::exec");
Bug#11747970 34660: CRASH WHEN FEDERATED TABLE LOSES CONNECTION DURING INSERT ... SELECT Problematic query: insert ignore into `t1_federated` (`c1`) select `c1` from `t1_local` a where not exists (select 1 from `t1_federated` b where a.c1 = b.c1); When this query is killed in another connection it could lead to crash. The problem is follwing: An attempt to obtain table statistics for subselect table in killed query fails with an error. So JOIN::optimize() for subquery is failed but it does not prevent further subquery evaluation. At the first subquery execution JOIN::optimize() is called (see subselect_single_select_engine::exec()) and fails with an error. 'executed' flag is set to TRUE and it prevents further subquery evaluation. At the second call JOIN::optimize() does not happen as 'JOIN::optimized' is TRUE and in case of uncacheable subquery the 'executed' flag is set to FALSE before subquery evaluation. So we loose 'optimize stage' error indication (see subselect_single_select_engine::exec()). In other words 'executed' flag is used for two purposes, for error indication at JOIN::optimize() stage and for an indication of subquery execution. And it seems it's wrong as the flag could be reset. mysql-test/r/error_simulation.result: test case mysql-test/t/error_simulation.test: test case sql/item_subselect.cc: added new flag subselect_single_select_engine::optimize_error which is used for error detection which could happen at optimize stage. sql/item_subselect.h: added new flag subselect_single_select_engine::optimize_error sql/sql_select.cc: test case
2011-10-05 11:28:20 +02:00
if (optimize_error)
DBUG_RETURN(1);
char const *save_where= thd->where;
SELECT_LEX *save_select= thd->lex->current_select;
thd->lex->current_select= select_lex;
if (!join->optimized)
{
Preparatory (and the most problematic) patch for Bug#7306 "the server side preparedStatement error for LIMIT placeholder", which moves all uses of LIMIT clause from PREPARE to OPTIMIZE and later steps. After-review fixes. mysql-test/r/group_min_max.result: Test results fixed for EXPLAINs when using GROUP_MIN_MAX access plan. sql/item_subselect.cc: Move setting of the internal LIMIT used for IN/ALL/ANY/EXISTS subqueries to one place: Item_exists_subselect::fix_length_and_dec(). This implies that unit->select_limit_cnt is not set until the item is fixed. This is OK, as now LIMIT values are not used until JOIN::optimize. sql/mysql_priv.h: setup_tables no longer needs a special flag for the case when it's called from JOIN::reinit() (we don't need to call setup_tables between two executions of a correlated subquery). sql/opt_range.cc: Fix a glitch in GROUP_MIN_MAX access plan: we should use table metadata, not field data, to evaluate max_used_key_length, which is then used for explain. sql/sp.cc: - setup_tables signature changed. sql/sql_base.cc: - setup_tables no longer needs a special mode for subqueries. Unused checks were removed. sql/sql_delete.cc: - setup_tables signature changed sql/sql_help.cc: - setup_tables signature changed sql/sql_insert.cc: - setup_tables signature changed sql/sql_lex.cc: Consolidate setting of internal LIMIT for IN/ALL/ANY/EXISTS subqeries in one place, and hence remove it from st_select_lex::test_limit(). sql/sql_lex.h: Cleanup signature of st_select_lex_unit::init_prepare_fake_select_lex(). sql/sql_load.cc: - setup_tables signature changed sql/sql_olap.cc: - setup_tables signature changed sql/sql_parse.cc: - st_select_lex_unit::set_limit() signature changed sql/sql_select.cc: Move setting of JOIN::select_limit from JOIN::prepare to JOIN::optimize. At prepare, limit is unknown yet. Remove excessive cleanups from JOIN::reinit which were overwriting join->join_tab[i]->table->used_keys. This fixes the bug which was triggered by the change in item_subselect.cc. sql/sql_union.cc: Class st_select_lex_unit was changed to avoid calls to st_select_lex_unit::set_limit from places where it may be unknown. Now unit->select_limit_cnt is set at ::exec(). st_select_lex_unit::init_prepare_fake_select_lex(): - move out set_limit functionality - remove a few lines of dead code. st_select_lex_unit::prepare(): - now we don't call set_limit at the time of prepare, so the value of unit->select_limit_cnt may be unknown here. Use sl->select_limit instead. st_select_lex_unit::exec(): - cleanup - call set_limit explicitly as it has been moved out of init_prepare_fake_select_lex. sql/sql_update.cc: - setup_tables signature changed
2005-05-30 18:54:37 +02:00
SELECT_LEX_UNIT *unit= select_lex->master_unit();
unit->set_limit(unit->global_parameters);
if (join->optimize())
{
thd->where= save_where;
executed= optimize_error= 1;
thd->lex->current_select= save_select;
handler interface cleanups: more logical table/index_flags return HA_ERR_WRONG_COMMAND instead of abstract methods where appropriate max_keys and other limits renamed to max_supported_keys/etc max_keys/etc are now wrappers to max_supported_keys/etc ha_index_init/ha_rnd_init/ha_index_end/ha_rnd_end are now wrappers to real {index,rnd}_{init,end} to enforce strict pairing include/myisam.h: increasing myisam_max_temp_file_length include/my_base.h: handler interface cleanup myisam/mi_static.c: warning removed mysql-test/Makefile.am: followup mysql-test/r/fulltext.result: fulltext indexes are not ordered mysql-test/r/rpl_user_variables.result: followup sql/field.cc: index_flags sql/filesort.cc: rnd_init -> ha_rnd_init rnd_end -> ha_rnd_end sql/ha_berkeley.cc: cleanup sql/ha_berkeley.h: table/index_flags revamped sql/ha_heap.cc: ensure index is accessed only after index_init (esp. important for temp tables) sql/ha_heap.h: table/index_flags revamped sql/ha_innodb.cc: don't workaround MySQL sloppiness sql/ha_innodb.h: table/index_flags revamped sql/ha_isam.h: table/index_flags revamped sql/ha_isammrg.h: table/index_flags revamped sql/ha_myisam.cc: ensure index is accessed only after index_init (esp. important for temp tables) sql/ha_myisam.h: table/index_flags revamped sql/ha_myisammrg.h: table/index_flags revamped sql/handler.cc: handler interface cleanups sql/handler.h: handler interface cleanups: more logical table/index_flags return HA_ERR_WRONG_COMMAND instead of abstract methods max_keys and other limits renamed to max_supported_keys/etc max_keys/etc are now wrappers to max_supported_keys/etc ha_index_init/ha_rnd_init/ha_index_end/ha_rnd_end are now wrappers to enforce strict pairing sql/item_subselect.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed sql/lex.h: renamed to avoid conflicts sql/opt_range.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed table/index_flags cleanup sql/opt_range.h: index_init/index_end/rnd_init/rnd_end strict pairing fixed sql/opt_sum.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed table/index_flags cleanup sql/records.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed sql/sql_acl.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed sql/sql_cache.cc: cleanup sql/sql_delete.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed sql/sql_handler.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed sql/sql_help.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed sql/sql_insert.cc: table/index_flags cleanup sql/sql_select.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed table/index_flags cleanup sql/sql_table.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed table/index_flags cleanup sql/sql_update.cc: index_init/index_end/rnd_init/rnd_end strict pairing fixed sql/sql_yacc.yy: INDEX -> INDEX_SYM sql/table.cc: table/index_flags cleanup
2004-06-23 12:29:05 +02:00
DBUG_RETURN(join->error ? join->error : 1);
}
if (!select_lex->uncacheable && thd->lex->describe &&
!(join->select_options & SELECT_DESCRIBE))
{
item->update_used_tables();
if (item->const_item())
{
/*
It's necessary to keep original JOIN table because
create_sort_index() function may overwrite original
JOIN_TAB::type and wrong optimization method can be
selected on re-execution.
*/
select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
/*
Force join->join_tmp creation, because this subquery will be replaced
by a simple select from the materialization temp table by optimize()
called by EXPLAIN and we need to preserve the initial query structure
so we can display it.
*/
if (join->need_tmp && join->init_save_join_tab())
DBUG_RETURN(1); /* purecov: inspected */
}
}
if (item->engine_changed)
{
DBUG_RETURN(1);
}
}
Bug#31048: Many nested subqueries may cause server crash. This bug is actually two. The first one manifests itself on an EXPLAIN SELECT query with nested subqueries that employs the filesort algorithm. The whole SELECT under explain is marked as UNCACHEABLE_EXPLAIN to preserve some temporary structures for explain. As a side-effect of this values of nested subqueries weren't cached and subqueries were re-evaluated many times. Each time buffer for filesort was allocated but wasn't freed because freeing occurs at the end of topmost SELECT. Thus all available memory was eaten up step by step and OOM event occur. The second bug manifests itself on SELECT queries with conditions where a subquery result is compared with a key field and the subquery itself also has such condition. When a long chain of such nested subqueries is present the stack overrun occur. This happens because at some point the range optimizer temporary puts the PARAM structure on the stack. Its size if about 8K and the stack is exhausted very fast. Now the subselect_single_select_engine::exec function allows subquery result caching when the UNCACHEABLE_EXPLAIN flag is set. Now the SQL_SELECT::test_quick_select function calls the check_stack_overrun function for stack checking purposes to prevent server crash. mysql-test/t/subselect.test: Added a test case for the bug#31048: Many nested subqueries may cause server crash. mysql-test/r/subselect.result: Added a test case for the bug#31048: Many nested subqueries may cause server crash. sql/opt_range.cc: Bug#31048: Many nested subqueries may cause server crash. Now the SQL_SELECT::test_quick_select function calls the check_stack_overrun function for stack checking purposes to preven server crash. sql/item_subselect.cc: Bug31048: Many nested subqueries may cause server crash. Now the subselect_single_select_engine::exec function allows subquery result caching when the UNCACHEABLE_EXPLAIN flag is set.
2007-11-19 21:00:25 +01:00
if (select_lex->uncacheable &&
select_lex->uncacheable != UNCACHEABLE_EXPLAIN
&& executed)
{
if (join->reinit())
{
thd->where= save_where;
thd->lex->current_select= save_select;
DBUG_RETURN(1);
}
item->reset();
item->assigned((executed= 0));
}
if (!executed)
{
item->reset_value_registration();
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
JOIN_TAB *changed_tabs[MAX_TABLES];
JOIN_TAB **last_changed_tab= changed_tabs;
if (item->have_guarded_conds())
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
{
/*
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
For at least one of the pushed predicates the following is true:
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
We should not apply optimizations based on the condition that was
pushed down into the subquery. Those optimizations are ref[_or_null]
acceses. Change them to be full table scans.
*/
for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES); tab;
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
{
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (tab && tab->keyuse)
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
{
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
for (uint i= 0; i < tab->ref.key_parts; i++)
{
bool *cond_guard= tab->ref.cond_guards[i];
if (cond_guard && !*cond_guard)
{
/* Change the access method to full table scan */
Fixed bug #28375: a query with an NOT IN subquery predicate may cause a crash when the left operand of the predicate is evaluated to NULL. It happens when the rows from the inner tables (tables from the subquery) are accessed by index methods with key values obtained by evaluation of the left operand of the subquery predicate. When this predicate is evaluated to NULL an alternative access with full table scan is used to check whether the result set returned by the subquery is empty or not. The crash was due to the fact the info about the access methods used for regular key values was not properly restored after a switch back from the full scan access method had occurred. The patch restores this info properly. The same problem existed for queries with IN subquery predicates if they were used not at the top level of the queries. mysql-test/r/subselect3.result: Added a test case for bug #28375. mysql-test/t/subselect3.test: Added a test case for bug #28375. sql/item_subselect.cc: Fixed bug #28375: a query with an NOT IN subquery predicate may cause a crash when the left operand of the predicate is evaluated to NULL. It happens when the rows from the inner tables (tables from the subquery) are accessed by index methods with key values obtained by evaluation of the left operand of the subquery predicate. When this predicate is evaluated to NULL an alternative access with full table scan is used to check whether the result set returned by the subquery is empty or not. The crash was due to the fact the info about the access methods used for regular key values was not properly restored after a switch back from the full scan access method had occurred. The patch restores this info properly. sql/sql_select.h: Fixed bug #28375: a query with an NOT IN subquery predicate may cause a crash when the left operand of the predicate is evaluated to NULL. In the JOIN_TAB structure two fields have been added to save info about index methods used to access the subquery rows. The saved info is used after a switch back from the alternative full scan access method has occurred. The full scan is used when the left operand of the subquery predicate is evaluated to NULL.
2007-05-12 04:37:32 +02:00
tab->save_read_first_record= tab->read_first_record;
tab->save_read_record= tab->read_record.read_record;
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
tab->read_first_record= init_read_record_seq;
tab->read_record.record= tab->table->record[0];
tab->read_record.thd= join->thd;
tab->read_record.ref_length= tab->table->file->ref_length;
A fix and a test case for Bug#41756 "Strange error messages about locks from InnoDB". In JT_EQ_REF (join_read_key()) access method, don't try to unlock rows in the handler, unless certain that a) they were locked b) they are not used. Unlocking of rows is done by the logic of the nested join loop, and is unaware of the possible caching that the access method may have. This could lead to double unlocking, when a row was unlocked first after reading into the cache, and then when taken from cache, as well as to unlocking of rows which were actually used (but taken from cache). Delegate part of the unlocking logic to the access method, and in JT_EQ_REF count how many times a record was actually used in the join. Unlock it only if it's usage count is 0. Implemented review comments. mysql-test/r/bug41756.result: Add result file (Bug#41756) mysql-test/t/bug41756-master.opt: Use --innodb-locks-unsafe-for-binlog, as in 5.0 just using read_committed isolation is not sufficient to reproduce the bug. mysql-test/t/bug41756.test: Add a test file (Bug#41756) sql/item_subselect.cc: Complete struct READ_RECORD initialization with a new member to unlock records. sql/records.cc: Extend READ_RECORD API with a method to unlock read records. sql/sql_select.cc: In JT_EQ_REF (join_read_key()) access method, don't try to unlock rows in the handler, unless certain that a) they were locked b) they are not used. sql/sql_select.h: Add members to TABLE_REF to count TABLE_REF buffer usage count. sql/structs.h: Update declarations.
2009-11-03 17:58:54 +01:00
tab->read_record.unlock_row= rr_unlock_row;
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
*(last_changed_tab++)= tab;
break;
}
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
}
}
}
join->exec();
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
/* Enable the optimizations back */
for (JOIN_TAB **ptab= changed_tabs; ptab != last_changed_tab; ptab++)
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
{
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
JOIN_TAB *tab= *ptab;
tab->read_record.record= 0;
tab->read_record.ref_length= 0;
Fixed bug #28375: a query with an NOT IN subquery predicate may cause a crash when the left operand of the predicate is evaluated to NULL. It happens when the rows from the inner tables (tables from the subquery) are accessed by index methods with key values obtained by evaluation of the left operand of the subquery predicate. When this predicate is evaluated to NULL an alternative access with full table scan is used to check whether the result set returned by the subquery is empty or not. The crash was due to the fact the info about the access methods used for regular key values was not properly restored after a switch back from the full scan access method had occurred. The patch restores this info properly. The same problem existed for queries with IN subquery predicates if they were used not at the top level of the queries. mysql-test/r/subselect3.result: Added a test case for bug #28375. mysql-test/t/subselect3.test: Added a test case for bug #28375. sql/item_subselect.cc: Fixed bug #28375: a query with an NOT IN subquery predicate may cause a crash when the left operand of the predicate is evaluated to NULL. It happens when the rows from the inner tables (tables from the subquery) are accessed by index methods with key values obtained by evaluation of the left operand of the subquery predicate. When this predicate is evaluated to NULL an alternative access with full table scan is used to check whether the result set returned by the subquery is empty or not. The crash was due to the fact the info about the access methods used for regular key values was not properly restored after a switch back from the full scan access method had occurred. The patch restores this info properly. sql/sql_select.h: Fixed bug #28375: a query with an NOT IN subquery predicate may cause a crash when the left operand of the predicate is evaluated to NULL. In the JOIN_TAB structure two fields have been added to save info about index methods used to access the subquery rows. The saved info is used after a switch back from the alternative full scan access method has occurred. The full scan is used when the left operand of the subquery predicate is evaluated to NULL.
2007-05-12 04:37:32 +02:00
tab->read_first_record= tab->save_read_first_record;
tab->read_record.read_record= tab->save_read_record;
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
}
executed= 1;
thd->where= save_where;
thd->lex->current_select= save_select;
DBUG_RETURN(join->error || thd->is_fatal_error || thd->is_error());
}
thd->where= save_where;
thd->lex->current_select= save_select;
DBUG_RETURN(0);
}
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
int subselect_union_engine::exec()
{
char const *save_where= thd->where;
int res= unit->exec();
thd->where= save_where;
return res;
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
/*
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
Search for at least one row satisfying select condition
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
SYNOPSIS
subselect_uniquesubquery_engine::scan_table()
DESCRIPTION
Scan the table using sequential access until we find at least one row
satisfying select condition.
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
The caller must set this->empty_result_set=FALSE before calling this
function. This function will set it to TRUE if it finds a matching row.
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
RETURN
FALSE - OK
TRUE - Error
*/
int subselect_uniquesubquery_engine::scan_table()
{
int error;
TABLE *table= tab->table;
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
DBUG_ENTER("subselect_uniquesubquery_engine::scan_table");
if (table->file->inited)
table->file->ha_index_end();
Fix for LP#588251: doStartTableScan() result not checked. The issue was that we didn't always check result of ha_rnd_init() which caused a problem for handlers that returned an error in this code. - Changed prototype of ha_rnd_init() to ensure that we get a compile warning if result is not checked. - Added ha_rnd_init_with_error() that prints error on failure. - Checked all usage of ha_rnd_init() and ensure we generate an error message on failures. - Changed init_read_record() to return 1 on failure. sql/create_options.cc: Fixed wrong printf sql/event_db_repository.cc: Check result from init_read_record() sql/events.cc: Check result from init_read_record() sql/filesort.cc: Check result from ha_rnd_init() sql/ha_partition.cc: Check result from ha_rnd_init() sql/ha_partition.h: Fixed compiler warning sql/handler.cc: Added ha_rnd_init_with_error() Check result from ha_rnd_init() sql/handler.h: Added ha_rnd_init_with_error() Changed prototype of ha_rnd_init() to ensure that we get a compile warning if result is not checked sql/item_subselect.cc: Check result from ha_rnd_init() sql/log.cc: Check result from ha_rnd_init() sql/log_event.cc: Check result from ha_rnd_init() sql/log_event_old.cc: Check result from ha_rnd_init() sql/mysql_priv.h: init_read_record() now returns error code on failure sql/opt_range.cc: Check result from ha_rnd_init() sql/records.cc: init_read_record() now returns error code on failure Check result from ha_rnd_init() sql/sql_acl.cc: Check result from init_read_record() sql/sql_cursor.cc: Print error if ha_rnd_init() fails sql/sql_delete.cc: Check result from init_read_record() sql/sql_help.cc: Check result from init_read_record() sql/sql_plugin.cc: Check result from init_read_record() sql/sql_select.cc: Check result from ha_rnd_init() Print error if ha_rnd_init() fails. sql/sql_servers.cc: Check result from init_read_record() sql/sql_table.cc: Check result from init_read_record() sql/sql_udf.cc: Check result from init_read_record() sql/sql_update.cc: Check result from init_read_record() storage/example/ha_example.cc: Don't return error on rnd_init() storage/ibmdb2i/ha_ibmdb2i.cc: Removed not relevant comment
2010-07-17 00:41:44 +02:00
if (table->file->ha_rnd_init_with_error(1))
DBUG_RETURN(1);
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
table->file->extra_opt(HA_EXTRA_CACHE,
current_thd->variables.read_buff_size);
table->null_row= 0;
for (;;)
{
This is based on the userstatv2 patch from Percona and OurDelta. The original code comes, as far as I know, from Google (Mark Callaghan's team) with additional work from Percona, Ourdelta and Weldon Whipple. This code provides the same functionallity, but with a lot of changes to make it faster and better fit the MariaDB infrastucture. Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_sent, Rows_read Added new variable / startup option 'userstat' to control if user statistics should be enabled or not Added my_getcputime(); Returns cpu time used by this thread. New FLUSH commands: - FLUSH SLOW QUERY LOG - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS New SHOW commands: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS New Information schemas: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Added support for all new flush commands to mysqladmin Added handler::ha_... wrappers for all handler read calls to do statistics counting - Changed all code to use new ha_... calls - Count number of read rows, changed rows and rows read trough an index Added counting of number of bytes sent to binary log (status variable Binlog_bytes_written) Added counting of access denied errors (status variable Access_denied_erors) Bugs fixed: - Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long - CLOCK_GETTIME was not propely working on Linuxm client/mysqladmin.cc: Added support for all new flush commmands and some common combinations: flush-slow-log flush-table-statistics flush-index-statistics flush-user-statistics flush-client-statistics flush-all-status flush-all-statistics configure.in: Added checking if clock_gettime needs the librt. (Fixes Bug #37639 clock_gettime is never used/enabled in Linux/Unix) include/my_sys.h: Added my_getcputime() include/mysql_com.h: Added LIST_PROCESS_HOST_LEN & new REFRESH target defines mysql-test/r/information_schema.result: New information schema tables added mysql-test/r/information_schema_all_engines.result: New information schema tables added mysql-test/r/information_schema_db.result: New information schema tables added mysql-test/r/log_slow.result: Added testing that flosh slow query logs is accepted mysql-test/r/status_user.result: Basic testing of user, client, table and index statistics mysql-test/t/log_slow.test: Added testing that flosh slow query logs is accepted mysql-test/t/status_user-master.opt: Ensure that we get a fresh restart before running status_user.test mysql-test/t/status_user.test: Basic testing of user, client, table and index statistics mysys/my_getsystime.c: Added my_getcputime() Returns cpu time used by this thread. sql/authors.h: Updated authors to have core and original MySQL developers first. sql/event_data_objects.cc: Updated call to mysql_reset_thd_for_next_command() sql/event_db_repository.cc: Changed to use new ha_... calls sql/filesort.cc: Changed to use new ha_... calls sql/ha_partition.cc: Changed to use new ha_... calls Fixed comment syntax sql/handler.cc: Changed to use new ha_... calls Reset table statistics Added code to update global table and index status Added counting of rows changed sql/handler.h: Added table and index statistics variables Added function reset_statistics() Added handler::ha_... wrappers for all handler read calls to do statistics counting Protected all normal read calls to ensure we use the new calls in the server. Made ha_partition a friend class so that partition code can call the old read functions sql/item_subselect.cc: Changed to use new ha_... calls sql/lex.h: Added keywords for new information schema tables and flush commands sql/log.cc: Added flush_slow_log() Added counting of number of bytes sent to binary log Removed not needed test of thd (It's used before, so it's safe to use) Added THD object to MYSQL_BIN_LOG::write_cache() to simplify statistics counting sql/log.h: Added new parameter to write_cache() Added flush_slow_log() functions. sql/log_event.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/log_event_old.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/mysql_priv.h: Updated call to mysql_reset_thd_for_next_command() Added new statistics functions and variables needed by these. sql/mysqld.cc: Added new statistics variables and structures to handle these Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_set, Rows_read Added new option 'userstat' to control if user statistics should be enabled or not sql/opt_range.cc: Changed to use new ha_... calls sql/opt_range.h: Changed to use new ha_... calls sql/opt_sum.cc: Changed to use new ha_... calls sql/records.cc: Changed to use new ha_... calls sql/set_var.cc: Added variable 'userstat' sql/sp.cc: Changed to use new ha_... calls sql/sql_acl.cc: Changed to use new ha_... calls Added counting of access_denied_errors sql/sql_base.cc: Added call to statistics functions sql/sql_class.cc: Added usage of org_status_var, to store status variables at start of command Added functions THD::update_stats(), THD::update_all_stats() Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long sql/sql_class.h: Added new status variables to status_var Moved variables that was not ulong in status_var last. Added variables to THD for storing temporary values during statistics counting sql/sql_connect.cc: Variables and functions to calculate user and client statistics Added counting of access_denied_errors and lost_connections sql/sql_cursor.cc: Changed to use new ha_... calls sql/sql_handler.cc: Changed to use new ha_... calls sql/sql_help.cc: Changed to use new ha_... calls sql/sql_insert.cc: Changed to use new ha_... calls sql/sql_lex.h: Added SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS, SQLCOM_SHOW_CLIENT_STATS sql/sql_parse.cc: Added handling of: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS Added handling of new FLUSH commands: - FLUSH SLOW QUERY LOGS - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS Added THD parameter to mysql_reset_thd_for_next_command() Added initialization and calls to user statistics functions Added increment of statistics variables empty_queries, rows_sent and access_denied_errors. Added counting of cpu time per query sql/sql_plugin.cc: Changed to use new ha_... calls sql/sql_prepare.cc: Updated call to mysql_reset_thd_for_next_command() sql/sql_select.cc: Changed to use new ha_... calls Indentation changes sql/sql_servers.cc: Changed to use new ha_... calls sql/sql_show.cc: Added counting of access denied errors Added function for new information schema tables: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Changed to use new ha_... calls sql/sql_table.cc: Changed to use new ha_... calls sql/sql_udf.cc: Changed to use new ha_... calls sql/sql_update.cc: Changed to use new ha_... calls sql/sql_yacc.yy: Add new show and flush commands sql/structs.h: Add name_length to KEY to avoid some strlen Added cache_name to KEY for fast storage of keyvalue in cache Added structs USER_STATS, TABLE_STATS, INDEX_STATS Added function prototypes for statistics functions sql/table.cc: Store db+table+index name into keyinfo->cache_name sql/table.h: Added new information schema tables sql/tztime.cc: Changed to use new ha_... calls
2009-10-19 19:14:48 +02:00
error=table->file->ha_rnd_next(table->record[0]);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (error) {
if (error == HA_ERR_RECORD_DELETED)
{
error= 0;
continue;
}
if (error == HA_ERR_END_OF_FILE)
{
error= 0;
break;
}
else
{
error= report_error(table, error);
break;
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
}
if (!cond || cond->val_int())
{
empty_result_set= FALSE;
break;
}
}
table->file->ha_rnd_end();
DBUG_RETURN(error != 0);
}
/*
Copy ref key and check for null parts in it
SYNOPSIS
subselect_uniquesubquery_engine::copy_ref_key()
DESCRIPTION
Copy ref key and check for null parts in it.
Depending on the nullability and conversion problems this function
recognizes and processes the following states :
1. Partial match on top level. This means IN has a value of FALSE
regardless of the data in the subquery table.
Detected by finding a NULL in the left IN operand of a top level
expression.
We may actually skip reading the subquery, so return TRUE to skip
the table scan in subselect_uniquesubquery_engine::exec and make
the value of the IN predicate a NULL (that is equal to FALSE on
top level).
2. No exact match when IN is nested inside another predicate.
Detected by finding a NULL in the left IN operand when IN is not
a top level predicate.
We cannot have an exact match. But we must proceed further with a
table scan to find out if it's a partial match (and IN has a value
of NULL) or no match (and IN has a value of FALSE).
So we return FALSE to continue with the scan and see if there are
any record that would constitute a partial match (as we cannot
determine that from the index).
3. Error converting the left IN operand to the column type of the
right IN operand. This counts as no match (and IN has the value of
FALSE). We mark the subquery table cursor as having no more rows
(to ensure that the processing that follows will not find a match)
and return FALSE, so IN is not treated as returning NULL.
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
RETURN
FALSE - The value of the IN predicate is not known. Proceed to find the
value of the IN predicate using the determined values of
null_keypart and table->status.
TRUE - IN predicate has a value of NULL. Stop the processing right there
and return NULL to the outer predicates.
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
*/
bool subselect_uniquesubquery_engine::copy_ref_key()
{
DBUG_ENTER("subselect_uniquesubquery_engine::copy_ref_key");
for (store_key **copy= tab->ref.key_copy ; *copy ; copy++)
{
if ((*copy)->store_key_is_const())
continue;
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
tab->ref.key_err= (*copy)->copy();
/*
When there is a NULL part in the key we don't need to make index
lookup for such key thus we don't need to copy whole key.
If we later should do a sequential scan return OK. Fail otherwise.
See also the comment for the subselect_uniquesubquery_engine::exec()
function.
*/
null_keypart= (*copy)->null_key;
if (null_keypart)
{
bool top_level= ((Item_in_subselect *) item)->is_top_level_item();
if (top_level)
{
/* Partial match on top level */
DBUG_RETURN(1);
}
else
{
/* No exact match when IN is nested inside another predicate */
break;
}
}
/*
Check if the error is equal to STORE_KEY_FATAL. This is not expressed
using the store_key::store_key_result enum because ref.key_err is a
boolean and we want to detect both TRUE and STORE_KEY_FATAL from the
space of the union of the values of [TRUE, FALSE] and
store_key::store_key_result.
TODO: fix the variable an return types.
*/
if (tab->ref.key_err & 1)
{
/*
Error converting the left IN operand to the column type of the right
IN operand.
*/
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
tab->table->status= STATUS_NOT_FOUND;
break;
}
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
DBUG_RETURN(0);
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
@retval 1 A NULL was found in the outer reference, index lookup is
not applicable, the outer ref is unsusable as a lookup key,
use some other method to find a match.
@retval 0 The outer ref was copied into an index lookup key.
@retval -1 The outer ref cannot possibly match any row, IN is FALSE.
*/
/* TIMOUR: this method is a variant of copy_ref_key(), needs refactoring. */
int subselect_uniquesubquery_engine::copy_ref_key_simple()
{
for (store_key **copy= tab->ref.key_copy ; *copy ; copy++)
{
enum store_key::store_key_result store_res;
store_res= (*copy)->copy();
tab->ref.key_err= store_res;
/*
When there is a NULL part in the key we don't need to make index
lookup for such key thus we don't need to copy whole key.
If we later should do a sequential scan return OK. Fail otherwise.
See also the comment for the subselect_uniquesubquery_engine::exec()
function.
*/
null_keypart= (*copy)->null_key;
if (null_keypart)
return 1;
/*
Check if the error is equal to STORE_KEY_FATAL. This is not expressed
using the store_key::store_key_result enum because ref.key_err is a
boolean and we want to detect both TRUE and STORE_KEY_FATAL from the
space of the union of the values of [TRUE, FALSE] and
store_key::store_key_result.
TODO: fix the variable an return types.
*/
if (store_res == store_key::STORE_KEY_FATAL)
{
/*
Error converting the left IN operand to the column type of the right
IN operand.
*/
return -1;
}
}
return 0;
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
/*
Execute subselect
SYNOPSIS
subselect_uniquesubquery_engine::exec()
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
DESCRIPTION
Find rows corresponding to the ref key using index access.
If some part of the lookup key is NULL, then we're evaluating
NULL IN (SELECT ... )
This is a special case, we don't need to search for NULL in the table,
instead, the result value is
- NULL if select produces empty row set
- FALSE otherwise.
In some cases (IN subselect is a top level item, i.e. abort_on_null==TRUE)
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
the caller doesn't distinguish between NULL and FALSE result and we just
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
return FALSE.
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
Otherwise we make a full table scan to see if there is at least one
matching row.
The result of this function (info about whether a row was found) is
stored in this->empty_result_set.
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
NOTE
RETURN
FALSE - ok
TRUE - an error occured while scanning
*/
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
int subselect_uniquesubquery_engine::exec()
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
{
DBUG_ENTER("subselect_uniquesubquery_engine::exec");
int error;
TABLE *table= tab->table;
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
empty_result_set= TRUE;
table->status= 0;
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
/* TODO: change to use of 'full_scan' here? */
if (copy_ref_key())
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
/*
TIMOUR: copy_ref_key() == 1 means NULL result, not error, why return 1?
Check who reiles on this result.
*/
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
DBUG_RETURN(1);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
if (table->status)
{
/*
We know that there will be no rows even if we scan.
Can be set in copy_ref_key.
*/
((Item_in_subselect *) item)->value= 0;
DBUG_RETURN(0);
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
if (!tab->preread_init_done && tab->preread_init())
DBUG_RETURN(1);
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
if (null_keypart)
DBUG_RETURN(scan_table());
if (!table->file->inited)
2005-07-18 13:31:02 +02:00
table->file->ha_index_init(tab->ref.key, 0);
This is based on the userstatv2 patch from Percona and OurDelta. The original code comes, as far as I know, from Google (Mark Callaghan's team) with additional work from Percona, Ourdelta and Weldon Whipple. This code provides the same functionallity, but with a lot of changes to make it faster and better fit the MariaDB infrastucture. Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_sent, Rows_read Added new variable / startup option 'userstat' to control if user statistics should be enabled or not Added my_getcputime(); Returns cpu time used by this thread. New FLUSH commands: - FLUSH SLOW QUERY LOG - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS New SHOW commands: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS New Information schemas: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Added support for all new flush commands to mysqladmin Added handler::ha_... wrappers for all handler read calls to do statistics counting - Changed all code to use new ha_... calls - Count number of read rows, changed rows and rows read trough an index Added counting of number of bytes sent to binary log (status variable Binlog_bytes_written) Added counting of access denied errors (status variable Access_denied_erors) Bugs fixed: - Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long - CLOCK_GETTIME was not propely working on Linuxm client/mysqladmin.cc: Added support for all new flush commmands and some common combinations: flush-slow-log flush-table-statistics flush-index-statistics flush-user-statistics flush-client-statistics flush-all-status flush-all-statistics configure.in: Added checking if clock_gettime needs the librt. (Fixes Bug #37639 clock_gettime is never used/enabled in Linux/Unix) include/my_sys.h: Added my_getcputime() include/mysql_com.h: Added LIST_PROCESS_HOST_LEN & new REFRESH target defines mysql-test/r/information_schema.result: New information schema tables added mysql-test/r/information_schema_all_engines.result: New information schema tables added mysql-test/r/information_schema_db.result: New information schema tables added mysql-test/r/log_slow.result: Added testing that flosh slow query logs is accepted mysql-test/r/status_user.result: Basic testing of user, client, table and index statistics mysql-test/t/log_slow.test: Added testing that flosh slow query logs is accepted mysql-test/t/status_user-master.opt: Ensure that we get a fresh restart before running status_user.test mysql-test/t/status_user.test: Basic testing of user, client, table and index statistics mysys/my_getsystime.c: Added my_getcputime() Returns cpu time used by this thread. sql/authors.h: Updated authors to have core and original MySQL developers first. sql/event_data_objects.cc: Updated call to mysql_reset_thd_for_next_command() sql/event_db_repository.cc: Changed to use new ha_... calls sql/filesort.cc: Changed to use new ha_... calls sql/ha_partition.cc: Changed to use new ha_... calls Fixed comment syntax sql/handler.cc: Changed to use new ha_... calls Reset table statistics Added code to update global table and index status Added counting of rows changed sql/handler.h: Added table and index statistics variables Added function reset_statistics() Added handler::ha_... wrappers for all handler read calls to do statistics counting Protected all normal read calls to ensure we use the new calls in the server. Made ha_partition a friend class so that partition code can call the old read functions sql/item_subselect.cc: Changed to use new ha_... calls sql/lex.h: Added keywords for new information schema tables and flush commands sql/log.cc: Added flush_slow_log() Added counting of number of bytes sent to binary log Removed not needed test of thd (It's used before, so it's safe to use) Added THD object to MYSQL_BIN_LOG::write_cache() to simplify statistics counting sql/log.h: Added new parameter to write_cache() Added flush_slow_log() functions. sql/log_event.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/log_event_old.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/mysql_priv.h: Updated call to mysql_reset_thd_for_next_command() Added new statistics functions and variables needed by these. sql/mysqld.cc: Added new statistics variables and structures to handle these Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_set, Rows_read Added new option 'userstat' to control if user statistics should be enabled or not sql/opt_range.cc: Changed to use new ha_... calls sql/opt_range.h: Changed to use new ha_... calls sql/opt_sum.cc: Changed to use new ha_... calls sql/records.cc: Changed to use new ha_... calls sql/set_var.cc: Added variable 'userstat' sql/sp.cc: Changed to use new ha_... calls sql/sql_acl.cc: Changed to use new ha_... calls Added counting of access_denied_errors sql/sql_base.cc: Added call to statistics functions sql/sql_class.cc: Added usage of org_status_var, to store status variables at start of command Added functions THD::update_stats(), THD::update_all_stats() Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long sql/sql_class.h: Added new status variables to status_var Moved variables that was not ulong in status_var last. Added variables to THD for storing temporary values during statistics counting sql/sql_connect.cc: Variables and functions to calculate user and client statistics Added counting of access_denied_errors and lost_connections sql/sql_cursor.cc: Changed to use new ha_... calls sql/sql_handler.cc: Changed to use new ha_... calls sql/sql_help.cc: Changed to use new ha_... calls sql/sql_insert.cc: Changed to use new ha_... calls sql/sql_lex.h: Added SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS, SQLCOM_SHOW_CLIENT_STATS sql/sql_parse.cc: Added handling of: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS Added handling of new FLUSH commands: - FLUSH SLOW QUERY LOGS - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS Added THD parameter to mysql_reset_thd_for_next_command() Added initialization and calls to user statistics functions Added increment of statistics variables empty_queries, rows_sent and access_denied_errors. Added counting of cpu time per query sql/sql_plugin.cc: Changed to use new ha_... calls sql/sql_prepare.cc: Updated call to mysql_reset_thd_for_next_command() sql/sql_select.cc: Changed to use new ha_... calls Indentation changes sql/sql_servers.cc: Changed to use new ha_... calls sql/sql_show.cc: Added counting of access denied errors Added function for new information schema tables: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Changed to use new ha_... calls sql/sql_table.cc: Changed to use new ha_... calls sql/sql_udf.cc: Changed to use new ha_... calls sql/sql_update.cc: Changed to use new ha_... calls sql/sql_yacc.yy: Add new show and flush commands sql/structs.h: Add name_length to KEY to avoid some strlen Added cache_name to KEY for fast storage of keyvalue in cache Added structs USER_STATS, TABLE_STATS, INDEX_STATS Added function prototypes for statistics functions sql/table.cc: Store db+table+index name into keyinfo->cache_name sql/table.h: Added new information schema tables sql/tztime.cc: Changed to use new ha_... calls
2009-10-19 19:14:48 +02:00
error= table->file->ha_index_read_map(table->record[0],
tab->ref.key_buff,
make_prev_keypart_map(tab->
ref.key_parts),
HA_READ_KEY_EXACT);
if (error &&
error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
error= report_error(table, error);
else
{
error= 0;
table->null_row= 0;
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (!table->status && (!cond || cond->val_int()))
{
((Item_in_subselect *) item)->value= 1;
empty_result_set= FALSE;
}
else
((Item_in_subselect *) item)->value= 0;
}
DBUG_RETURN(error != 0);
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
TIMOUR: write comment
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
*/
int subselect_uniquesubquery_engine::index_lookup()
{
DBUG_ENTER("subselect_uniquesubquery_engine::index_lookup");
int error;
TABLE *table= tab->table;
if (!table->file->inited)
table->file->ha_index_init(tab->ref.key, 0);
error= table->file->ha_index_read_map(table->record[0],
tab->ref.key_buff,
make_prev_keypart_map(tab->
ref.key_parts),
HA_READ_KEY_EXACT);
DBUG_PRINT("info", ("lookup result: %i", error));
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
if (error && error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/*
TIMOUR: I don't understand at all when do we need to call report_error.
In most places where we access an index, we don't do this. Why here?
*/
error= report_error(table, error);
DBUG_RETURN(error);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
table->null_row= 0;
if (!error && (!cond || cond->val_int()))
((Item_in_subselect *) item)->value= 1;
else
((Item_in_subselect *) item)->value= 0;
DBUG_RETURN(0);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
subselect_uniquesubquery_engine::~subselect_uniquesubquery_engine()
{
/* Tell handler we don't need the index anymore */
//psergey-merge-todo: the following was gone in 6.0:
//psergey-merge: don't need this after all: tab->table->file->ha_index_end();
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
/*
Index-lookup subselect 'engine' - run the subquery
SYNOPSIS
subselect_indexsubquery_engine:exec()
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
full_scan
DESCRIPTION
The engine is used to resolve subqueries in form
oe IN (SELECT key FROM tbl WHERE subq_where)
The value of the predicate is calculated as follows:
1. If oe IS NULL, this is a special case, do a full table scan on
table tbl and search for row that satisfies subq_where. If such
row is found, return NULL, otherwise return FALSE.
2. Make an index lookup via key=oe, search for a row that satisfies
subq_where. If found, return TRUE.
3. If check_null==TRUE, make another lookup via key=NULL, search for a
row that satisfies subq_where. If found, return NULL, otherwise
return FALSE.
TODO
The step #1 can be optimized further when the index has several key
parts. Consider a subquery:
(oe1, oe2) IN (SELECT keypart1, keypart2 FROM tbl WHERE subq_where)
and suppose we need to evaluate it for {oe1, oe2}=={const1, NULL}.
Current code will do a full table scan and obtain correct result. There
is a better option: instead of evaluating
SELECT keypart1, keypart2 FROM tbl WHERE subq_where (1)
and checking if it has produced any matching rows, evaluate
SELECT keypart2 FROM tbl WHERE subq_where AND keypart1=const1 (2)
If this query produces a row, the result is NULL (as we're evaluating
"(const1, NULL) IN { (const1, X), ... }", which has a value of UNKNOWN,
i.e. NULL). If the query produces no rows, the result is FALSE.
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
We currently evaluate (1) by doing a full table scan. (2) can be
evaluated by doing a "ref" scan on "keypart1=const1", which can be much
cheaper. We can use index statistics to quickly check whether "ref" scan
will be cheaper than full table scan.
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
RETURN
0
1
*/
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
int subselect_indexsubquery_engine::exec()
{
DBUG_ENTER("subselect_indexsubquery_engine");
int error;
bool null_finding= 0;
TABLE *table= tab->table;
((Item_in_subselect *) item)->value= 0;
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
empty_result_set= TRUE;
null_keypart= 0;
Fixed bug #28076: inconsistent binary/varbinary comparison. After adding an index the <VARBINARY> IN (SELECT <BINARY> ...) clause returned a wrong result: the VARBINARY value was illegally padded with zero bytes to the length of the BINARY column for the index search. (<VARBINARY>, ...) IN (SELECT <BINARY>, ... ) clauses are affected too. sql/item.cc: Fixed bug #28076. The Item_cache_str::save_in_field method has been overloaded to check cached values for an illegal padding before the saving into a field. sql/item.h: Fixed bug #28076. The Item_cache_str::is_varbinary flag has been added and the Item_cache_str::save_in_field method has been overloaded to prevent cached values from an illegal padding when saving in fields. The signature of the Item_cache::get_cache method has been changed to accept pointers to Item instead of Item_result values. sql/item_cmpfunc.cc: Fixed bug #28076. The Item_in_optimizer::fix_left method has been modified to to call Item_cache::get_cache in a new manner. sql/item_subselect.cc: Fixed bug #28076. The subselect_indexsubquery_engine::exec method has been modified to take into account field conversion errors (copy&paste from subselect_uniquesubquery_engine::exec). sql/sp_rcontext.cc: Fixed bug #28076. The sp_rcontext::create_case_expr_holder method has been modified to call Item_cache::get_cache in a new manner. sql/sp_rcontext.h: Fixed bug #28076. The sp_rcontext::create_case_expr_holder method signature has been modified to pass Item pointers to the Item_cache::get_cache method. sql/sql_class.cc: Fixed bug #28076. The select_max_min_finder_subselect::send_data method has been modified to call Item_cache::get_cache in a new manner. mysql-test/t/subselect.test: Added test case for bug #28076. mysql-test/r/subselect.result: Added test case for bug #28076.
2007-11-10 20:44:48 +01:00
table->status= 0;
if (check_null)
{
/* We need to check for NULL if there wasn't a matching value */
*tab->ref.null_ref_key= 0; // Search first for not null
((Item_in_subselect *) item)->was_null= 0;
}
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
/* Copy the ref key and check for nulls... */
if (copy_ref_key())
DBUG_RETURN(1);
Fixed bug #28076: inconsistent binary/varbinary comparison. After adding an index the <VARBINARY> IN (SELECT <BINARY> ...) clause returned a wrong result: the VARBINARY value was illegally padded with zero bytes to the length of the BINARY column for the index search. (<VARBINARY>, ...) IN (SELECT <BINARY>, ... ) clauses are affected too. sql/item.cc: Fixed bug #28076. The Item_cache_str::save_in_field method has been overloaded to check cached values for an illegal padding before the saving into a field. sql/item.h: Fixed bug #28076. The Item_cache_str::is_varbinary flag has been added and the Item_cache_str::save_in_field method has been overloaded to prevent cached values from an illegal padding when saving in fields. The signature of the Item_cache::get_cache method has been changed to accept pointers to Item instead of Item_result values. sql/item_cmpfunc.cc: Fixed bug #28076. The Item_in_optimizer::fix_left method has been modified to to call Item_cache::get_cache in a new manner. sql/item_subselect.cc: Fixed bug #28076. The subselect_indexsubquery_engine::exec method has been modified to take into account field conversion errors (copy&paste from subselect_uniquesubquery_engine::exec). sql/sp_rcontext.cc: Fixed bug #28076. The sp_rcontext::create_case_expr_holder method has been modified to call Item_cache::get_cache in a new manner. sql/sp_rcontext.h: Fixed bug #28076. The sp_rcontext::create_case_expr_holder method signature has been modified to pass Item pointers to the Item_cache::get_cache method. sql/sql_class.cc: Fixed bug #28076. The select_max_min_finder_subselect::send_data method has been modified to call Item_cache::get_cache in a new manner. mysql-test/t/subselect.test: Added test case for bug #28076. mysql-test/r/subselect.result: Added test case for bug #28076.
2007-11-10 20:44:48 +01:00
if (table->status)
{
/*
We know that there will be no rows even if we scan.
Can be set in copy_ref_key.
*/
((Item_in_subselect *) item)->value= 0;
DBUG_RETURN(0);
}
if (!tab->preread_init_done && tab->preread_init())
DBUG_RETURN(1);
BUG#8804: wrong results for NULL IN (SELECT ...) Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down conditions and their "consequences": = Do full table scans instead of unique_[index_subquery] lookups. = Change appropriate "ref_or_null" accesses to full table scans in subquery's joins. Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated wrt any upper select. mysql-test/r/subselect.result: BUG#8804: wrong results for NULL IN (SELECT ...): - Updated test results sql/item.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added comments sql/item_cmpfunc.cc: BUG#8804: wrong results for NULL IN (SELECT ...): Made Item_in_optimizer to: - cache the value of "NULL IN (uncorrelated select)" - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)" sql/item_cmpfunc.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)" - Added comments sql/item_subselect.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - When needed, wrap the predicates we push into subquery into an Item_func_trig_cond so we're able to turn them off when evaluating NULL IN (SELECT ...). - Added code to evaluate NULL IN (SELECT ...) in a special way: = In [unique_]index_subquery, do full table scan to see if there are any rows. = For other subqueries, change ref[_or_null] to ALL if the ref[_or_null] was created from pushed-down predicate. sql/item_subselect.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added Item_subselect::is_correlated - Added comments sql/records.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Make rr_sequential() non-static sql/sql_lex.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated and Item_subselect::is_correlated. sql/sql_lex.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added st_select_lex::is_correlated sql/sql_select.cc: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEY_FIELD::outer_ref to keep track of which ref accesses are created from predicates that were pushed down into the subquery. sql/sql_select.h: BUG#8804: wrong results for NULL IN (SELECT ...): - Added KEYUSE::outer_ref mysql-test/r/subselect3.result: New BitKeeper file ``mysql-test/r/subselect3.result'' mysql-test/t/subselect3.test: New BitKeeper file ``mysql-test/t/subselect3.test''
2006-10-31 18:51:09 +01:00
if (null_keypart)
DBUG_RETURN(scan_table());
if (!table->file->inited)
2005-07-18 13:31:02 +02:00
table->file->ha_index_init(tab->ref.key, 1);
This is based on the userstatv2 patch from Percona and OurDelta. The original code comes, as far as I know, from Google (Mark Callaghan's team) with additional work from Percona, Ourdelta and Weldon Whipple. This code provides the same functionallity, but with a lot of changes to make it faster and better fit the MariaDB infrastucture. Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_sent, Rows_read Added new variable / startup option 'userstat' to control if user statistics should be enabled or not Added my_getcputime(); Returns cpu time used by this thread. New FLUSH commands: - FLUSH SLOW QUERY LOG - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS New SHOW commands: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS New Information schemas: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Added support for all new flush commands to mysqladmin Added handler::ha_... wrappers for all handler read calls to do statistics counting - Changed all code to use new ha_... calls - Count number of read rows, changed rows and rows read trough an index Added counting of number of bytes sent to binary log (status variable Binlog_bytes_written) Added counting of access denied errors (status variable Access_denied_erors) Bugs fixed: - Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long - CLOCK_GETTIME was not propely working on Linuxm client/mysqladmin.cc: Added support for all new flush commmands and some common combinations: flush-slow-log flush-table-statistics flush-index-statistics flush-user-statistics flush-client-statistics flush-all-status flush-all-statistics configure.in: Added checking if clock_gettime needs the librt. (Fixes Bug #37639 clock_gettime is never used/enabled in Linux/Unix) include/my_sys.h: Added my_getcputime() include/mysql_com.h: Added LIST_PROCESS_HOST_LEN & new REFRESH target defines mysql-test/r/information_schema.result: New information schema tables added mysql-test/r/information_schema_all_engines.result: New information schema tables added mysql-test/r/information_schema_db.result: New information schema tables added mysql-test/r/log_slow.result: Added testing that flosh slow query logs is accepted mysql-test/r/status_user.result: Basic testing of user, client, table and index statistics mysql-test/t/log_slow.test: Added testing that flosh slow query logs is accepted mysql-test/t/status_user-master.opt: Ensure that we get a fresh restart before running status_user.test mysql-test/t/status_user.test: Basic testing of user, client, table and index statistics mysys/my_getsystime.c: Added my_getcputime() Returns cpu time used by this thread. sql/authors.h: Updated authors to have core and original MySQL developers first. sql/event_data_objects.cc: Updated call to mysql_reset_thd_for_next_command() sql/event_db_repository.cc: Changed to use new ha_... calls sql/filesort.cc: Changed to use new ha_... calls sql/ha_partition.cc: Changed to use new ha_... calls Fixed comment syntax sql/handler.cc: Changed to use new ha_... calls Reset table statistics Added code to update global table and index status Added counting of rows changed sql/handler.h: Added table and index statistics variables Added function reset_statistics() Added handler::ha_... wrappers for all handler read calls to do statistics counting Protected all normal read calls to ensure we use the new calls in the server. Made ha_partition a friend class so that partition code can call the old read functions sql/item_subselect.cc: Changed to use new ha_... calls sql/lex.h: Added keywords for new information schema tables and flush commands sql/log.cc: Added flush_slow_log() Added counting of number of bytes sent to binary log Removed not needed test of thd (It's used before, so it's safe to use) Added THD object to MYSQL_BIN_LOG::write_cache() to simplify statistics counting sql/log.h: Added new parameter to write_cache() Added flush_slow_log() functions. sql/log_event.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/log_event_old.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/mysql_priv.h: Updated call to mysql_reset_thd_for_next_command() Added new statistics functions and variables needed by these. sql/mysqld.cc: Added new statistics variables and structures to handle these Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_set, Rows_read Added new option 'userstat' to control if user statistics should be enabled or not sql/opt_range.cc: Changed to use new ha_... calls sql/opt_range.h: Changed to use new ha_... calls sql/opt_sum.cc: Changed to use new ha_... calls sql/records.cc: Changed to use new ha_... calls sql/set_var.cc: Added variable 'userstat' sql/sp.cc: Changed to use new ha_... calls sql/sql_acl.cc: Changed to use new ha_... calls Added counting of access_denied_errors sql/sql_base.cc: Added call to statistics functions sql/sql_class.cc: Added usage of org_status_var, to store status variables at start of command Added functions THD::update_stats(), THD::update_all_stats() Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long sql/sql_class.h: Added new status variables to status_var Moved variables that was not ulong in status_var last. Added variables to THD for storing temporary values during statistics counting sql/sql_connect.cc: Variables and functions to calculate user and client statistics Added counting of access_denied_errors and lost_connections sql/sql_cursor.cc: Changed to use new ha_... calls sql/sql_handler.cc: Changed to use new ha_... calls sql/sql_help.cc: Changed to use new ha_... calls sql/sql_insert.cc: Changed to use new ha_... calls sql/sql_lex.h: Added SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS, SQLCOM_SHOW_CLIENT_STATS sql/sql_parse.cc: Added handling of: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS Added handling of new FLUSH commands: - FLUSH SLOW QUERY LOGS - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS Added THD parameter to mysql_reset_thd_for_next_command() Added initialization and calls to user statistics functions Added increment of statistics variables empty_queries, rows_sent and access_denied_errors. Added counting of cpu time per query sql/sql_plugin.cc: Changed to use new ha_... calls sql/sql_prepare.cc: Updated call to mysql_reset_thd_for_next_command() sql/sql_select.cc: Changed to use new ha_... calls Indentation changes sql/sql_servers.cc: Changed to use new ha_... calls sql/sql_show.cc: Added counting of access denied errors Added function for new information schema tables: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Changed to use new ha_... calls sql/sql_table.cc: Changed to use new ha_... calls sql/sql_udf.cc: Changed to use new ha_... calls sql/sql_update.cc: Changed to use new ha_... calls sql/sql_yacc.yy: Add new show and flush commands sql/structs.h: Add name_length to KEY to avoid some strlen Added cache_name to KEY for fast storage of keyvalue in cache Added structs USER_STATS, TABLE_STATS, INDEX_STATS Added function prototypes for statistics functions sql/table.cc: Store db+table+index name into keyinfo->cache_name sql/table.h: Added new information schema tables sql/tztime.cc: Changed to use new ha_... calls
2009-10-19 19:14:48 +02:00
error= table->file->ha_index_read_map(table->record[0],
tab->ref.key_buff,
make_prev_keypart_map(tab->
ref.key_parts),
HA_READ_KEY_EXACT);
if (error &&
error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
error= report_error(table, error);
else
{
for (;;)
{
error= 0;
table->null_row= 0;
if (!table->status)
{
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if ((!cond || cond->val_int()) && (!having || having->val_int()))
{
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
empty_result_set= FALSE;
if (null_finding)
((Item_in_subselect *) item)->was_null= 1;
else
((Item_in_subselect *) item)->value= 1;
break;
}
This is based on the userstatv2 patch from Percona and OurDelta. The original code comes, as far as I know, from Google (Mark Callaghan's team) with additional work from Percona, Ourdelta and Weldon Whipple. This code provides the same functionallity, but with a lot of changes to make it faster and better fit the MariaDB infrastucture. Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_sent, Rows_read Added new variable / startup option 'userstat' to control if user statistics should be enabled or not Added my_getcputime(); Returns cpu time used by this thread. New FLUSH commands: - FLUSH SLOW QUERY LOG - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS New SHOW commands: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS New Information schemas: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Added support for all new flush commands to mysqladmin Added handler::ha_... wrappers for all handler read calls to do statistics counting - Changed all code to use new ha_... calls - Count number of read rows, changed rows and rows read trough an index Added counting of number of bytes sent to binary log (status variable Binlog_bytes_written) Added counting of access denied errors (status variable Access_denied_erors) Bugs fixed: - Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long - CLOCK_GETTIME was not propely working on Linuxm client/mysqladmin.cc: Added support for all new flush commmands and some common combinations: flush-slow-log flush-table-statistics flush-index-statistics flush-user-statistics flush-client-statistics flush-all-status flush-all-statistics configure.in: Added checking if clock_gettime needs the librt. (Fixes Bug #37639 clock_gettime is never used/enabled in Linux/Unix) include/my_sys.h: Added my_getcputime() include/mysql_com.h: Added LIST_PROCESS_HOST_LEN & new REFRESH target defines mysql-test/r/information_schema.result: New information schema tables added mysql-test/r/information_schema_all_engines.result: New information schema tables added mysql-test/r/information_schema_db.result: New information schema tables added mysql-test/r/log_slow.result: Added testing that flosh slow query logs is accepted mysql-test/r/status_user.result: Basic testing of user, client, table and index statistics mysql-test/t/log_slow.test: Added testing that flosh slow query logs is accepted mysql-test/t/status_user-master.opt: Ensure that we get a fresh restart before running status_user.test mysql-test/t/status_user.test: Basic testing of user, client, table and index statistics mysys/my_getsystime.c: Added my_getcputime() Returns cpu time used by this thread. sql/authors.h: Updated authors to have core and original MySQL developers first. sql/event_data_objects.cc: Updated call to mysql_reset_thd_for_next_command() sql/event_db_repository.cc: Changed to use new ha_... calls sql/filesort.cc: Changed to use new ha_... calls sql/ha_partition.cc: Changed to use new ha_... calls Fixed comment syntax sql/handler.cc: Changed to use new ha_... calls Reset table statistics Added code to update global table and index status Added counting of rows changed sql/handler.h: Added table and index statistics variables Added function reset_statistics() Added handler::ha_... wrappers for all handler read calls to do statistics counting Protected all normal read calls to ensure we use the new calls in the server. Made ha_partition a friend class so that partition code can call the old read functions sql/item_subselect.cc: Changed to use new ha_... calls sql/lex.h: Added keywords for new information schema tables and flush commands sql/log.cc: Added flush_slow_log() Added counting of number of bytes sent to binary log Removed not needed test of thd (It's used before, so it's safe to use) Added THD object to MYSQL_BIN_LOG::write_cache() to simplify statistics counting sql/log.h: Added new parameter to write_cache() Added flush_slow_log() functions. sql/log_event.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/log_event_old.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/mysql_priv.h: Updated call to mysql_reset_thd_for_next_command() Added new statistics functions and variables needed by these. sql/mysqld.cc: Added new statistics variables and structures to handle these Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_set, Rows_read Added new option 'userstat' to control if user statistics should be enabled or not sql/opt_range.cc: Changed to use new ha_... calls sql/opt_range.h: Changed to use new ha_... calls sql/opt_sum.cc: Changed to use new ha_... calls sql/records.cc: Changed to use new ha_... calls sql/set_var.cc: Added variable 'userstat' sql/sp.cc: Changed to use new ha_... calls sql/sql_acl.cc: Changed to use new ha_... calls Added counting of access_denied_errors sql/sql_base.cc: Added call to statistics functions sql/sql_class.cc: Added usage of org_status_var, to store status variables at start of command Added functions THD::update_stats(), THD::update_all_stats() Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long sql/sql_class.h: Added new status variables to status_var Moved variables that was not ulong in status_var last. Added variables to THD for storing temporary values during statistics counting sql/sql_connect.cc: Variables and functions to calculate user and client statistics Added counting of access_denied_errors and lost_connections sql/sql_cursor.cc: Changed to use new ha_... calls sql/sql_handler.cc: Changed to use new ha_... calls sql/sql_help.cc: Changed to use new ha_... calls sql/sql_insert.cc: Changed to use new ha_... calls sql/sql_lex.h: Added SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS, SQLCOM_SHOW_CLIENT_STATS sql/sql_parse.cc: Added handling of: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS Added handling of new FLUSH commands: - FLUSH SLOW QUERY LOGS - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS Added THD parameter to mysql_reset_thd_for_next_command() Added initialization and calls to user statistics functions Added increment of statistics variables empty_queries, rows_sent and access_denied_errors. Added counting of cpu time per query sql/sql_plugin.cc: Changed to use new ha_... calls sql/sql_prepare.cc: Updated call to mysql_reset_thd_for_next_command() sql/sql_select.cc: Changed to use new ha_... calls Indentation changes sql/sql_servers.cc: Changed to use new ha_... calls sql/sql_show.cc: Added counting of access denied errors Added function for new information schema tables: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Changed to use new ha_... calls sql/sql_table.cc: Changed to use new ha_... calls sql/sql_udf.cc: Changed to use new ha_... calls sql/sql_update.cc: Changed to use new ha_... calls sql/sql_yacc.yy: Add new show and flush commands sql/structs.h: Add name_length to KEY to avoid some strlen Added cache_name to KEY for fast storage of keyvalue in cache Added structs USER_STATS, TABLE_STATS, INDEX_STATS Added function prototypes for statistics functions sql/table.cc: Store db+table+index name into keyinfo->cache_name sql/table.h: Added new information schema tables sql/tztime.cc: Changed to use new ha_... calls
2009-10-19 19:14:48 +02:00
error= table->file->ha_index_next_same(table->record[0],
tab->ref.key_buff,
tab->ref.key_length);
if (error && error != HA_ERR_END_OF_FILE)
{
error= report_error(table, error);
break;
}
}
else
{
if (!check_null || null_finding)
break; /* We don't need to check nulls */
*tab->ref.null_ref_key= 1;
null_finding= 1;
/* Check if there exists a row with a null value in the index */
if ((error= (safe_index_read(tab) == 1)))
break;
}
}
}
DBUG_RETURN(error != 0);
}
uint subselect_single_select_engine::cols()
{
//psergey-sj-backport: the following assert was gone in 6.0:
//DBUG_ASSERT(select_lex->join != 0); // should be called after fix_fields()
//return select_lex->join->fields_list.elements;
return select_lex->item_list.elements;
}
uint subselect_union_engine::cols()
{
DBUG_ASSERT(unit->is_prepared()); // should be called after fix_fields()
return unit->types.elements;
}
uint8 subselect_single_select_engine::uncacheable()
{
return select_lex->uncacheable;
}
uint8 subselect_union_engine::uncacheable()
{
return unit->uncacheable;
}
fixed * without tables in IN bug fixed sunction-test select in IN bug fixed unions in subselect bug include/mysqld_error.h: new warning mysql-test/r/subselect.result: test of * without tables in IN test of sunction-test select in IN test of unions in subselect mysql-test/t/subselect.test: test of * without tables in IN test of sunction-test select in IN test of unions in subselect sql/item.cc: fixed * substitution without tables sql/item_subselect.cc: fixed subselect rewriting with function-test subselect sql/item_subselect.h: mechanism for subselect removing sql/share/czech/errmsg.txt: new warning sql/share/danish/errmsg.txt: new warning sql/share/dutch/errmsg.txt: new warning sql/share/english/errmsg.txt: new warning sql/share/estonian/errmsg.txt: new warning sql/share/french/errmsg.txt: new warning sql/share/german/errmsg.txt: new warning sql/share/greek/errmsg.txt: new warning sql/share/hungarian/errmsg.txt: new warning sql/share/italian/errmsg.txt: new warning sql/share/japanese/errmsg.txt: new warning sql/share/korean/errmsg.txt: new warning sql/share/norwegian-ny/errmsg.txt: new warning sql/share/norwegian/errmsg.txt: new warning sql/share/polish/errmsg.txt: new warning sql/share/portuguese/errmsg.txt: new warning sql/share/romanian/errmsg.txt: new warning sql/share/russian/errmsg.txt: new warning sql/share/serbian/errmsg.txt: new warning sql/share/slovak/errmsg.txt: new warning sql/share/spanish/errmsg.txt: new warning sql/share/swedish/errmsg.txt: new warning sql/share/ukrainian/errmsg.txt: new warning sql/sql_base.cc: fixed case on no name field in UNION subselect sql/sql_lex.cc: mechanisp of removing single subselect for optimisation purposes sql/sql_lex.h: mechanisp of removing single subselect for optimisation purposes sql/sql_parse.cc: error handling sql/sql_union.cc: fixed unions in subselect sql/sql_yacc.yy: fixed Lex->describe flag appearence
2002-11-28 18:29:26 +01:00
void subselect_single_select_engine::exclude()
{
select_lex->master_unit()->exclude_level();
}
void subselect_union_engine::exclude()
{
unit->exclude_level();
}
void subselect_uniquesubquery_engine::exclude()
{
//this never should be called
DBUG_ASSERT(0);
}
table_map subselect_engine::calc_const_tables(List<TABLE_LIST> &list)
{
table_map map= 0;
List_iterator<TABLE_LIST> ti(list);
TABLE_LIST *table;
//for (; table; table= table->next_leaf)
while ((table= ti++))
{
TABLE *tbl= table->table;
if (tbl && tbl->const_table)
map|= tbl->map;
}
return map;
}
table_map subselect_single_select_engine::upper_select_const_tables()
{
Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. One somewhat major source of strict-aliasing violations and related warnings is the SQL_LIST structure. For example, consider its member function `link_in_list` which takes a pointer to pointer of type T (any type) as a pointer to pointer to unsigned char. Dereferencing this pointer, which is done to reset the next field, violates strict-aliasing rules and might cause problems for surrounding code that uses the next field of the object being added to the list. The solution is to use templates to parametrize the SQL_LIST structure in order to deference the pointers with compatible types. As a side bonus, it becomes possible to remove quite a few casts related to acessing data members of SQL_LIST. sql/handler.h: Use the appropriate template type argument. sql/item.cc: Remove now-unnecessary cast. sql/item_subselect.cc: Remove now-unnecessary casts. sql/item_sum.cc: Use the appropriate template type argument. Remove now-unnecessary cast. sql/mysql_priv.h: Move SQL_LIST structure to sql_list.h Use the appropriate template type argument. sql/sp.cc: Remove now-unnecessary casts. sql/sql_delete.cc: Use the appropriate template type argument. Remove now-unnecessary casts. sql/sql_derived.cc: Remove now-unnecessary casts. sql/sql_lex.cc: Remove now-unnecessary casts. sql/sql_lex.h: SQL_LIST now takes a template type argument which must match the type of the elements of the list. Use forward declaration when the type is not available, it is used in pointers anyway. sql/sql_list.h: Rename SQL_LIST to SQL_I_List. The template parameter is the type of object that is stored in the list. sql/sql_olap.cc: Remove now-unnecessary casts. sql/sql_parse.cc: Remove now-unnecessary casts. sql/sql_prepare.cc: Remove now-unnecessary casts. sql/sql_select.cc: Remove now-unnecessary casts. sql/sql_show.cc: Remove now-unnecessary casts. sql/sql_table.cc: Remove now-unnecessary casts. sql/sql_trigger.cc: Remove now-unnecessary casts. sql/sql_union.cc: Remove now-unnecessary casts. sql/sql_update.cc: Remove now-unnecessary casts. sql/sql_view.cc: Remove now-unnecessary casts. sql/sql_yacc.yy: Remove now-unnecessary casts. storage/myisammrg/ha_myisammrg.cc: Remove now-unnecessary casts.
2010-06-10 22:45:22 +02:00
return calc_const_tables(select_lex->outer_select()->leaf_tables);
}
table_map subselect_union_engine::upper_select_const_tables()
{
Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. One somewhat major source of strict-aliasing violations and related warnings is the SQL_LIST structure. For example, consider its member function `link_in_list` which takes a pointer to pointer of type T (any type) as a pointer to pointer to unsigned char. Dereferencing this pointer, which is done to reset the next field, violates strict-aliasing rules and might cause problems for surrounding code that uses the next field of the object being added to the list. The solution is to use templates to parametrize the SQL_LIST structure in order to deference the pointers with compatible types. As a side bonus, it becomes possible to remove quite a few casts related to acessing data members of SQL_LIST. sql/handler.h: Use the appropriate template type argument. sql/item.cc: Remove now-unnecessary cast. sql/item_subselect.cc: Remove now-unnecessary casts. sql/item_sum.cc: Use the appropriate template type argument. Remove now-unnecessary cast. sql/mysql_priv.h: Move SQL_LIST structure to sql_list.h Use the appropriate template type argument. sql/sp.cc: Remove now-unnecessary casts. sql/sql_delete.cc: Use the appropriate template type argument. Remove now-unnecessary casts. sql/sql_derived.cc: Remove now-unnecessary casts. sql/sql_lex.cc: Remove now-unnecessary casts. sql/sql_lex.h: SQL_LIST now takes a template type argument which must match the type of the elements of the list. Use forward declaration when the type is not available, it is used in pointers anyway. sql/sql_list.h: Rename SQL_LIST to SQL_I_List. The template parameter is the type of object that is stored in the list. sql/sql_olap.cc: Remove now-unnecessary casts. sql/sql_parse.cc: Remove now-unnecessary casts. sql/sql_prepare.cc: Remove now-unnecessary casts. sql/sql_select.cc: Remove now-unnecessary casts. sql/sql_show.cc: Remove now-unnecessary casts. sql/sql_table.cc: Remove now-unnecessary casts. sql/sql_trigger.cc: Remove now-unnecessary casts. sql/sql_union.cc: Remove now-unnecessary casts. sql/sql_update.cc: Remove now-unnecessary casts. sql/sql_view.cc: Remove now-unnecessary casts. sql/sql_yacc.yy: Remove now-unnecessary casts. storage/myisammrg/ha_myisammrg.cc: Remove now-unnecessary casts.
2010-06-10 22:45:22 +02:00
return calc_const_tables(unit->outer_select()->leaf_tables);
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
void subselect_single_select_engine::print(String *str,
enum_query_type query_type)
{
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
select_lex->print(thd, str, query_type);
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
void subselect_union_engine::print(String *str, enum_query_type query_type)
{
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
unit->print(str, query_type);
}
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
void subselect_uniquesubquery_engine::print(String *str,
enum_query_type query_type)
{
char *table_name= tab->table->s->table_name.str;
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN("<primary_index_lookup>("));
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
tab->ref.items[0]->print(str, query_type);
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN(" in "));
if (tab->table->s->table_category == TABLE_CATEGORY_TEMPORARY)
{
/*
Temporary tables' names change across runs, so they can't be used for
EXPLAIN EXTENDED.
*/
str->append(STRING_WITH_LEN("<temporary table>"));
}
else
str->append(table_name, tab->table->s->table_name.length);
KEY *key_info= tab->table->key_info+ tab->ref.key;
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN(" on "));
str->append(key_info->name);
if (cond)
{
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN(" where "));
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
cond->print(str, query_type);
}
str->append(')');
}
/*
TODO:
The above ::print method should be changed as below. Do it after
all other tests pass.
void subselect_uniquesubquery_engine::print(String *str)
{
KEY *key_info= tab->table->key_info + tab->ref.key;
str->append(STRING_WITH_LEN("<primary_index_lookup>("));
for (uint i= 0; i < key_info->key_parts; i++)
tab->ref.items[i]->print(str);
str->append(STRING_WITH_LEN(" in "));
str->append(tab->table->s->table_name.str, tab->table->s->table_name.length);
str->append(STRING_WITH_LEN(" on "));
str->append(key_info->name);
if (cond)
{
str->append(STRING_WITH_LEN(" where "));
cond->print(str);
}
str->append(')');
}
*/
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
void subselect_indexsubquery_engine::print(String *str,
enum_query_type query_type)
{
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN("<index_lookup>("));
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
tab->ref.items[0]->print(str, query_type);
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN(" in "));
Table definition cache, part 2 The table opening process now works the following way: - Create common TABLE_SHARE object - Read the .frm file and unpack it into the TABLE_SHARE object - Create a TABLE object based on the information in the TABLE_SHARE object and open a handler to the table object Other noteworthy changes: - In TABLE_SHARE the most common strings are now LEX_STRING's - Better error message when table is not found - Variable table_cache is now renamed 'table_open_cache' - New variable 'table_definition_cache' that is the number of table defintions that will be cached - strxnmov() calls are now fixed to avoid overflows - strxnmov() will now always add one end \0 to result - engine objects are now created with a TABLE_SHARE object instead of a TABLE object. - After creating a field object one must call field->init(table) before using it - For a busy system this change will give you: - Less memory usage for table object - Faster opening of tables (if it's has been in use or is in table definition cache) - Allow you to cache many table definitions objects - Faster drop of table mysql-test/mysql-test-run.sh: Fixed some problems with --gdb option Test both with socket and tcp/ip port that all old servers are killed mysql-test/r/flush_table.result: More tests with lock table with 2 threads + flush table mysql-test/r/information_schema.result: Removed old (now wrong) result mysql-test/r/innodb.result: Better error messages (thanks to TDC patch) mysql-test/r/merge.result: Extra flush table test mysql-test/r/ndb_bitfield.result: Better error messages (thanks to TDC patch) mysql-test/r/ndb_partition_error.result: Better error messages (thanks to TDC patch) mysql-test/r/query_cache.result: Remove tables left from old tests mysql-test/r/temp_table.result: Test truncate with temporary tables mysql-test/r/variables.result: Table_cache -> Table_open_cache mysql-test/t/flush_table.test: More tests with lock table with 2 threads + flush table mysql-test/t/merge.test: Extra flush table test mysql-test/t/multi_update.test: Added 'sleep' to make test predictable mysql-test/t/query_cache.test: Remove tables left from old tests mysql-test/t/temp_table.test: Test truncate with temporary tables mysql-test/t/variables.test: Table_cache -> Table_open_cache mysql-test/valgrind.supp: Remove warning that may happens becasue threads dies in different order mysys/hash.c: Fixed wrong DBUG_PRINT mysys/mf_dirname.c: More DBUG mysys/mf_pack.c: Better comment mysys/mf_tempdir.c: More DBUG Ensure that we call cleanup_dirname() on all temporary directory paths. If we don't do this, we will get a failure when comparing temporary table names as in some cases the temporary table name is run through convert_dirname()) mysys/my_alloc.c: Indentation fix sql/examples/ha_example.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_example.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_tina.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/examples/ha_tina.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/field.cc: Update for table definition cache: - Field creation now takes TABLE_SHARE instead of TABLE as argument (This is becasue field definitions are now cached in TABLE_SHARE) When a field is created, one now must call field->init(TABLE) before using it - Use s->db instead of s->table_cache_key - Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE - make_field() takes TABLE_SHARE as argument instead of TABLE - move_field() -> move_field_offset() sql/field.h: Update for table definition cache: - Field creation now takes TABLE_SHARE instead of TABLE as argument (This is becasue field definitions are now cached in TABLE_SHARE) When a field is created, one now must call field->init(TABLE) before using it - Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE - make_field() takes TABLE_SHARE as argument instead of TABLE - move_field() -> move_field_offset() sql/ha_archive.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_archive.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_berkeley.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Changed name of argument create() to not hide internal 'table' variable. table->s -> table_share sql/ha_berkeley.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_blackhole.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_blackhole.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_federated.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Fixed comments Remove index variable and replace with pointers (simple optimization) move_field() -> move_field_offset() Removed some strlen() calls sql/ha_federated.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_heap.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Simplify delete_table() and create() as the given file names are now without extension sql/ha_heap.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_innodb.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_innodb.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_myisam.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Remove not needed fn_format() Fixed for new table->s structure sql/ha_myisam.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_myisammrg.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Don't set 'is_view' for MERGE tables Use new interface to find_temporary_table() sql/ha_myisammrg.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers Added flag HA_NO_COPY_ON_ALTER sql/ha_ndbcluster.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers Fixed wrong calls to strxnmov() Give error HA_ERR_TABLE_DEF_CHANGED if table definition has changed drop_table -> intern_drop_table() table->s -> table_share Move part_info to TABLE Fixed comments & DBUG print's New arguments to print_error() sql/ha_ndbcluster.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers sql/ha_partition.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers We can't set up or use part_info when creating handler as there is not yet any table object New ha_intialise() to work with TDC (Done by Mikael) sql/ha_partition.h: We new use TABLE_SHARE instead of TABLE when creating engine handlers Got set_part_info() from Mikael sql/handler.cc: We new use TABLE_SHARE instead of TABLE when creating engine handlers ha_delete_table() now also takes database as an argument handler::ha_open() now takes TABLE as argument ha_open() now calls ha_allocate_read_write_set() Simplify ha_allocate_read_write_set() Remove ha_deallocate_read_write_set() Use table_share (Cached by table definition cache) sql/handler.h: New table flag: HA_NO_COPY_ON_ALTER (used by merge tables) Remove ha_deallocate_read_write_set() get_new_handler() now takes TABLE_SHARE as argument ha_delete_table() now gets database as argument sql/item.cc: table_name and db are now LEX_STRING objects When creating fields, we have now have to call field->init(table) move_field -> move_field_offset() sql/item.h: tmp_table_field_from_field_type() now takes an extra paramenter 'fixed_length' to allow one to force usage of CHAR instead of BLOB sql/item_cmpfunc.cc: Fixed call to tmp_table_field_from_field_type() sql/item_create.cc: Assert if new not handled cast type sql/item_func.cc: When creating fields, we have now have to call field->init(table) dummy_table used by 'sp' now needs a TABLE_SHARE object sql/item_subselect.cc: Trivial code cleanups sql/item_sum.cc: When creating fields, we have now have to call field->init(table) sql/item_timefunc.cc: Item_func_str_to_date::tmp_table_field() now replaced by call to tmp_table_field_from_field_type() (see item_timefunc.h) sql/item_timefunc.h: Simply tmp_table_field() sql/item_uniq.cc: When creating fields, we have now have to call field->init(table) sql/key.cc: Added 'KEY' argument to 'find_ref_key' to simplify code sql/lock.cc: More debugging Use create_table_def_key() to create key for table cache Allocate TABLE_SHARE properly when creating name lock Fix that locked_table_name doesn't test same table twice sql/mysql_priv.h: New functions for table definition cache New interfaces to a lot of functions. New faster interface to find_temporary_table() and close_temporary_table() sql/mysqld.cc: Added support for table definition cache of size 'table_def_size' Fixed som calls to strnmov() Changed name of 'table_cache' to 'table_open_cache' sql/opt_range.cc: Use new interfaces Fixed warnings from valgrind sql/parse_file.cc: Safer calls to strxnmov() Fixed typo sql/set_var.cc: Added variable 'table_definition_cache' Variable table_cache renamed to 'table_open_cache' sql/slave.cc: Use new interface sql/sp.cc: Proper use of TABLE_SHARE sql/sp_head.cc: Remove compiler warnings We have now to call field->init(table) sql/sp_head.h: Pointers to parsed strings are now const sql/sql_acl.cc: table_name is now a LEX_STRING sql/sql_base.cc: Main implementation of table definition cache (The #ifdef's are there for the future when table definition cache will replace open table cache) Now table definitions are cached indepndent of open tables, which will speed up things when a table is in use at once from several places Views are not yet cached; For the moment we only cache if a table is a view or not. Faster implementation of find_temorary_table() Replace 'wait_for_refresh()' with the more general function 'wait_for_condition()' Drop table is slightly faster as we can use the table definition cache to know the type of the table sql/sql_cache.cc: table_cache_key and table_name are now LEX_STRING 'sDBUG print fixes sql/sql_class.cc: table_cache_key is now a LEX_STRING safer strxnmov() sql/sql_class.h: Added number of open table shares (table definitions) sql/sql_db.cc: safer strxnmov() sql/sql_delete.cc: Use new interface to find_temporary_table() sql/sql_derived.cc: table_name is now a LEX_STRING sql/sql_handler.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's sql/sql_insert.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's sql/sql_lex.cc: Make parsed string a const (to quickly find out if anything is trying to change the query string) sql/sql_lex.h: Make parsed string a const (to quickly find out if anything is trying to change the query string) sql/sql_load.cc: Safer strxnmov() sql/sql_parse.cc: Better error if wrong DB name sql/sql_partition.cc: part_info moved to TABLE from TABLE_SHARE Indentation changes sql/sql_select.cc: Indentation fixes Call field->init(TABLE) for new created fields Update create_tmp_table() to use TABLE_SHARE properly sql/sql_select.h: Call field->init(TABLE) for new created fields sql/sql_show.cc: table_name is now a LEX_STRING part_info moved to TABLE sql/sql_table.cc: Use table definition cache to speed up delete of tables Fixed calls to functions with new interfaces Don't use 'share_not_to_be_used' Instead of doing openfrm() when doing repair, we now have to call get_table_share() followed by open_table_from_share(). Replace some fn_format() with faster unpack_filename(). Safer strxnmov() part_info is now in TABLE Added Mikaels patch for partition and ALTER TABLE Instead of using 'TABLE_SHARE->is_view' use 'table_flags() & HA_NO_COPY_ON_ALTER sql/sql_test.cc: table_name and table_cache_key are now LEX_STRING's sql/sql_trigger.cc: TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's safer strxnmov() Removed compiler warnings sql/sql_update.cc: Call field->init(TABLE) after field is created sql/sql_view.cc: safer strxnmov() Create common TABLE_SHARE object for views to allow us to cache if table is a view sql/structs.h: Added SHOW_TABLE_DEFINITIONS sql/table.cc: Creation and destruct of TABLE_SHARE objects that are common for many TABLE objects The table opening process now works the following way: - Create common TABLE_SHARE object - Read the .frm file and unpack it into the TABLE_SHARE object - Create a TABLE object based on the information in the TABLE_SHARE object and open a handler to the table object open_table_def() is written in such a way that it should be trival to add parsing of the .frm files in new formats sql/table.h: TABLE objects for the same database table now share a common TABLE_SHARE object In TABLE_SHARE the most common strings are now LEX_STRING's sql/unireg.cc: Changed arguments to rea_create_table() to have same order as other functions Call field->init(table) for new created fields sql/unireg.h: Added OPEN_VIEW strings/strxnmov.c: Change strxnmov() to always add end \0 This makes usage of strxnmov() safer as most of MySQL code assumes that strxnmov() will create a null terminated string
2005-11-23 21:45:02 +01:00
str->append(tab->table->s->table_name.str, tab->table->s->table_name.length);
KEY *key_info= tab->table->key_info+ tab->ref.key;
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN(" on "));
str->append(key_info->name);
if (check_null)
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN(" checking NULL"));
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (cond)
{
Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). A hook for unknown keys added to the parser to support old .TRG files. sql/field.cc: Inefficient usage of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/ha_berkeley.cc: A bad example of usage of a string with its length fixed. sql/ha_federated.cc: Inefficient usage of String::append() fixed. sql/ha_myisammrg.cc: Bad examples of usage of a string with its length fixed. sql/handler.cc: Inefficient usage of String::append() fixed. sql/item.cc: Bad examples of usage of a string with its length fixed. sql/item.h: A bad example of usage of a string with its length fixed. sql/item_cmpfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_func.cc: Bad examples of usage of a string with its length fixed. sql/item_strfunc.cc: Bad examples of usage of a string with its length fixed. sql/item_subselect.cc: Bad examples of usage of a string with its length fixed. sql/item_sum.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/item_timefunc.cc: Inefficient using of String::append() fixed. Bad examples of usage of a string with its length fixed. sql/item_uniq.h: Bad examples of usage of a string with its length fixed. sql/key.cc: Bad examples of usage of a string with its length fixed. sql/log.cc: Bad examples of usage of a string with its length fixed. sql/log_event.cc: Bad examples of usage of a string with its length fixed. sql/mysqld.cc: The dummy parser hook allocated. sql/opt_range.cc: Inefficient usage of String::append() fixed. sql/parse_file.cc: Bad examples of usage of a string with its length fixed. A hook for unknown keys added to the parser. sql/parse_file.h: A hook for unknown keys added to the parser. sql/protocol.cc: A bad example of usage of a string with its length fixed. sql/repl_failsafe.cc: Bad examples of usage of a string with its length fixed. sql/share/errmsg.txt: A warning for old format config file. sql/slave.cc: Bad examples of usage of a string with its length fixed. sql/sp.cc: Bad examples of usage of a string with its length fixed. sql/sp_head.cc: Bad examples of usage of a string with its length fixed. sql/spatial.cc: A bad example of usage of a string with its length fixed. sql/sql_acl.cc: Bad examples of usage of a string with its length fixed. sql/sql_analyse.cc: Bad examples of usage of a string with its length fixed. Inefficient usage of String::append() fixed. sql/sql_lex.cc: Bad examples of usage of a string with its length fixed. sql/sql_load.cc: A bad example of usage of a string with its length fixed. sql/sql_parse.cc: Bad examples of usage of a string with its length fixed. sql/sql_prepare.cc: A bad example of usage of a string with its length fixed. sql/sql_select.cc: Bad examples of usage of a string with its length fixed. sql/sql_show.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.cc: Bad examples of usage of a string with its length fixed. sql/sql_string.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/sql_table.cc: Bad examples of usage of a string with its length fixed. sql/sql_trigger.cc: Bad examples of usage of a string with its length fixed. The incorrect length in the trigger file configuration descriptor fixed (BUG#14090). The hook for processing incorrect sql_mode record added. sql/sql_view.cc: A dummy hook used for parsing views. sql/structs.h: The macro definition moved to sql_string.h to be accessible in all parts of server. sql/table.cc: A bad example of usage of a string with its length fixed. sql/tztime.cc: A bad example of usage of a string with its length fixed.
2005-11-20 19:47:07 +01:00
str->append(STRING_WITH_LEN(" where "));
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
cond->print(str, query_type);
}
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
if (having)
{
str->append(STRING_WITH_LEN(" having "));
Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print().
2008-02-22 11:30:33 +01:00
having->print(str, query_type);
BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs: - Make the code produce correct result: use an array of triggers to turn on/off equalities for each compared column. Also turn on/off optimizations based on those equalities. - Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between ref/unique_subquery/index_subquery and ALL access. - index_subquery engine now has HAVING clause when it is needed, and it is displayed in EXPLAIN EXTENDED - Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930) // bk trigger note: this commit refers to BUG#24127 mysql-test/r/ndb_subquery.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect2.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Updated test results (checked) mysql-test/r/subselect3.result: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases mysql-test/t/subselect3.test: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Testcases sql/item_cmpfunc.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before running the subquery. sql/item_cmpfunc.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added Item_func_trig_cond::get_triv_var() sql/item_subselect.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/item_subselect.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter anymore - now Item_subselect owns the pushed down predicates guard flags. - A correct set of conditional predicates is now pushed into row-based IN subquery. - select_indexsubquery_engine now has "HAVING clause" (needed for correct query results), and it is shown in EXPLAIN EXTENDED sql/mysql_priv.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/mysqld.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Added "in_having_cond" special Item name sql/sql_lex.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) sql/sql_select.cc: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix subquery optimization code to match the changes in what kinds of conditions are pushed down into subqueries - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390) sql/sql_select.h: BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...) - Make "ref" analyzer be able to work with conditional equalities - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 21:22:41 +01:00
}
str->append(')');
}
2007-10-11 19:29:09 +02:00
/**
change select_result object of engine.
2007-10-11 19:29:09 +02:00
@param si new subselect Item
@param res new select_result object
@param temp temporary assignment
2007-10-11 19:29:09 +02:00
@retval
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
FALSE OK
2007-10-11 19:29:09 +02:00
@retval
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
TRUE error
*/
bool
subselect_single_select_engine::change_result(Item_subselect *si,
select_result_interceptor *res,
bool temp)
{
item= si;
if (temp)
{
/*
Here we reuse change_item_tree to roll back assignment. It has
nothing special about Item* pointer so it is safe conversion. We do
not change the interface to be compatible with MySQL.
*/
thd->change_item_tree((Item**) &result, (Item*)res);
}
else
result= res;
/*
We can't use 'result' below as gcc 4.2.4's alias optimization
assumes that result was not changed by thd->change_item_tree().
I tried to find a solution to make gcc happy, but could not find anything
that would not require a lot of extra code that would be harder to manage
than the current code.
*/
return select_lex->join->change_result(res);
}
2007-10-11 19:29:09 +02:00
/**
change select_result object of engine.
2007-10-11 19:29:09 +02:00
@param si new subselect Item
@param res new select_result object
2007-10-11 19:29:09 +02:00
@retval
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
FALSE OK
2007-10-11 19:29:09 +02:00
@retval
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
TRUE error
*/
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
bool subselect_union_engine::change_result(Item_subselect *si,
select_result_interceptor *res,
bool temp)
{
item= si;
int rc= unit->change_result(res, result);
if (temp)
thd->change_item_tree((Item**) &result, (Item*)res);
else
result= res;
return rc;
}
2007-10-11 19:29:09 +02:00
/**
change select_result emulation, never should be called.
2007-10-11 19:29:09 +02:00
@param si new subselect Item
@param res new select_result object
2007-10-11 19:29:09 +02:00
@retval
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
FALSE OK
2007-10-11 19:29:09 +02:00
@retval
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
TRUE error
*/
bool
subselect_uniquesubquery_engine::change_result(Item_subselect *si,
select_result_interceptor *res,
bool temp
__attribute__((unused)))
{
DBUG_ASSERT(0);
errors without code removed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed (WL#2133) include/mysqld_error.h: new errors added. mysql-test/r/rpl_charset.result: new error mysql-test/r/rpl_timezone.result: new error mysql-test/r/sp-security.result: more clean error message mysql-test/r/sp.result: now error state intercepted correctly mysql-test/t/connect.test: new error message mysql-test/t/rpl_charset.test: new error message mysql-test/t/rpl_timezone.test: new error mysql-test/t/sp-security.test: more correct error handling mysql-test/t/sp.test: now error state intercepted correctly sql/ha_innodb.cc: -1/1 (sent/unsent) error reporting removed sql/ha_innodb.h: -1/1 (sent/unsent) error reporting removed sql/item.cc: only boolean values should be returned by fix_fields() sql/item_cmpfunc.cc: only boolean values should be returned by fix_fields() sql/item_func.cc: only boolean values should be returned by fix_fields() net_printf/send_error calls replaced by my_error family functions sql/item_row.cc: only boolean values should be returned by fix_fields() sql/item_subselect.cc: only boolean values should be returned by fix_fields() -1/1 (sent/unsent) error reporting removed sql/item_subselect.h: -1/1 (sent/unsent) error reporting removed sql/item_sum.cc: only boolean values should be returned by fix_fields() sql/item_timefunc.cc: only boolean values should be returned by fix_fields() sql/item_uniq.h: only boolean values should be returned by fix_fields() sql/mysql_priv.h: -1/1 (sent/unsent) error reporting removed sql/mysqld.cc: net_printf/send_error calls replaced by my_error family functions changes in my_message_sql to support error handling correctly sql/protocol.cc: net_printf/send_error calls replaced by my_error family functions sql/protocol_cursor.cc: net_printf/send_error calls replaced by my_error family functions sql/repl_failsafe.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/repl_failsafe.h: -1/1 (sent/unsent) error reporting removed sql/set_var.cc: net_printf/send_error calls replaced by my_error family functions sql/share/czech/errmsg.txt: new error messages sql/share/danish/errmsg.txt: new error messages sql/share/dutch/errmsg.txt: new error messages sql/share/english/errmsg.txt: new error messages sql/share/estonian/errmsg.txt: new error messages sql/share/french/errmsg.txt: new error messages sql/share/german/errmsg.txt: new error messages sql/share/greek/errmsg.txt: new error messages sql/share/hungarian/errmsg.txt: new error messages sql/share/italian/errmsg.txt: new error messages sql/share/japanese/errmsg.txt: new error messages sql/share/korean/errmsg.txt: new error messages sql/share/norwegian-ny/errmsg.txt: new error messages sql/share/norwegian/errmsg.txt: new error messages sql/share/polish/errmsg.txt: new error messages sql/share/portuguese/errmsg.txt: new error messages sql/share/romanian/errmsg.txt: new error messages sql/share/russian/errmsg.txt: new error messages sql/share/serbian/errmsg.txt: new error messages sql/share/slovak/errmsg.txt: new error messages sql/share/spanish/errmsg.txt: new error messages sql/share/swedish/errmsg.txt: new error messages sql/share/ukrainian/errmsg.txt: new error messages sql/slave.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/slave.h: -1/1 (sent/unsent) error reporting removed sql/sp.cc: net_printf/send_error calls replaced by my_error family functions sql/sp_head.cc: new eror handling support net_printf/send_error calls replaced by my_error family functions sql/sp_rcontext.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_acl.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_acl.h: -1/1 (sent/unsent) error reporting removed sql/sql_base.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_class.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_class.h: my_messhage_sql now set/reset query_error flag sql/sql_db.cc: -1/1 (sent/unsent) error reporting removed sql/sql_delete.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_do.cc: -1/1 (sent/unsent) error reporting removed sql/sql_error.cc: -1/1 (sent/unsent) error reporting removed sql/sql_handler.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_help.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_insert.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_lex.h: -1/1 (sent/unsent) error reporting removed sql/sql_load.cc: -1/1 (sent/unsent) error reporting removed sql/sql_map.cc: errors without code removed sql/sql_parse.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed from mysql_execute_command sql/sql_prepare.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.cc: error messages fixed net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_repl.h: -1/1 (sent/unsent) error reporting removed sql/sql_select.cc: -1/1 (sent/unsent) error reporting removed sql/sql_select.h: -1/1 (sent/unsent) error reporting removed sql/sql_show.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_table.cc: net_printf/send_error calls replaced by my_error family functions -1/1 (sent/unsent) error reporting removed sql/sql_trigger.cc: -1/1 (sent/unsent) error reporting removed sql/sql_udf.cc: net_printf/send_error calls replaced by my_error family functions sql/sql_union.cc: -1/1 (sent/unsent) error reporting removed sql/sql_update.cc: -1/1 (sent/unsent) error reporting removed net_printf/send_error calls replaced by my_error family functions sql/sql_view.cc: -1/1 (sent/unsent) error reporting removed sql/sql_view.h: -1/1 (sent/unsent) error reporting removed sql/sql_yacc.yy: net_printf/send_error calls replaced by my_error family functions
2004-10-20 03:04:37 +02:00
return TRUE;
}
2007-10-11 19:29:09 +02:00
/**
Report about presence of tables in subquery.
2007-10-11 19:29:09 +02:00
@retval
TRUE there are not tables used in subquery
2007-10-11 19:29:09 +02:00
@retval
FALSE there are some tables in subquery
*/
bool subselect_single_select_engine::no_tables()
{
return(select_lex->table_list.elements == 0);
}
/*
Check statically whether the subquery can return NULL
SINOPSYS
subselect_single_select_engine::may_be_null()
RETURN
FALSE can guarantee that the subquery never return NULL
TRUE otherwise
*/
bool subselect_single_select_engine::may_be_null()
{
return ((no_tables() && !join->conds && !join->having) ? maybe_null : 1);
}
2007-10-11 19:29:09 +02:00
/**
Report about presence of tables in subquery.
2007-10-11 19:29:09 +02:00
@retval
TRUE there are not tables used in subquery
2007-10-11 19:29:09 +02:00
@retval
FALSE there are some tables in subquery
*/
bool subselect_union_engine::no_tables()
{
for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
{
if (sl->table_list.elements)
return FALSE;
}
return TRUE;
}
2007-10-11 19:29:09 +02:00
/**
Report about presence of tables in subquery.
2007-10-11 19:29:09 +02:00
@retval
TRUE there are not tables used in subquery
2007-10-11 19:29:09 +02:00
@retval
FALSE there are some tables in subquery
*/
bool subselect_uniquesubquery_engine::no_tables()
{
/* returning value is correct, but this method should never be called */
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
DBUG_ASSERT(FALSE);
return 0;
}
/******************************************************************************
WL#1110 - Implementation of class subselect_hash_sj_engine
******************************************************************************/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/**
Check if an IN predicate should be executed via partial matching using
only schema information.
@details
This test essentially has three results:
- partial matching is applicable, but cannot be executed due to a
limitation in the total number of indexes, as a result we can't
use subquery materialization at all.
- partial matching is either applicable or not, and this can be
determined by looking at 'this->max_keys'.
If max_keys > 1, then we need partial matching because there are
more indexes than just the one we use during materialization to
remove duplicates.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
@note
TIMOUR: The schema-based analysis for partial matching can be done once for
prepared statement and remembered. It is done here to remove the need to
save/restore all related variables between each re-execution, thus making
the code simpler.
@retval PARTIAL_MATCH if a partial match should be used
@retval COMPLETE_MATCH if a complete match (index lookup) should be used
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
*/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
subselect_hash_sj_engine::exec_strategy
subselect_hash_sj_engine::get_strategy_using_schema()
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
Item_in_subselect *item_in= (Item_in_subselect *) item;
if (item_in->is_top_level_item())
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
return COMPLETE_MATCH;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
else
{
List_iterator<Item> inner_col_it(*item_in->unit->get_unit_column_types());
Item *outer_col, *inner_col;
for (uint i= 0; i < item_in->left_expr->cols(); i++)
{
outer_col= item_in->left_expr->element_index(i);
inner_col= inner_col_it++;
if (!inner_col->maybe_null && !outer_col->maybe_null)
bitmap_set_bit(&non_null_key_parts, i);
else
{
bitmap_set_bit(&partial_match_key_parts, i);
++count_partial_match_columns;
}
}
}
/* If no column contains NULLs use regular hash index lookups. */
if (count_partial_match_columns)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
return PARTIAL_MATCH;
return COMPLETE_MATCH;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
/**
Test whether an IN predicate must be computed via partial matching
based on the NULL statistics for each column of a materialized subquery.
@details The procedure analyzes column NULL statistics, updates the
matching type of columns that cannot be NULL or that contain only NULLs.
Based on this, the procedure determines the final execution strategy for
the [NOT] IN predicate.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
@retval PARTIAL_MATCH if a partial match should be used
@retval COMPLETE_MATCH if a complete match (index lookup) should be used
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
*/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
subselect_hash_sj_engine::exec_strategy
subselect_hash_sj_engine::get_strategy_using_data()
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
Item_in_subselect *item_in= (Item_in_subselect *) item;
select_materialize_with_stats *result_sink=
(select_materialize_with_stats *) result;
Item *outer_col;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/*
If we already determined that a complete match is enough based on schema
information, nothing can be better.
*/
if (strategy == COMPLETE_MATCH)
return COMPLETE_MATCH;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
for (uint i= 0; i < item_in->left_expr->cols(); i++)
{
if (!bitmap_is_set(&partial_match_key_parts, i))
continue;
outer_col= item_in->left_expr->element_index(i);
/*
If column 'i' doesn't contain NULLs, and the corresponding outer reference
cannot have a NULL value, then 'i' is a non-nullable column.
*/
if (result_sink->get_null_count_of_col(i) == 0 && !outer_col->maybe_null)
{
bitmap_clear_bit(&partial_match_key_parts, i);
bitmap_set_bit(&non_null_key_parts, i);
--count_partial_match_columns;
}
if (result_sink->get_null_count_of_col(i) == tmp_table->file->stats.records)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
++count_null_only_columns;
if (result_sink->get_null_count_of_col(i))
++count_columns_with_nulls;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
/* If no column contains NULLs use regular hash index lookups. */
if (!count_partial_match_columns)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
return COMPLETE_MATCH;
return PARTIAL_MATCH;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
void
subselect_hash_sj_engine::choose_partial_match_strategy(
bool has_non_null_key, bool has_covering_null_row,
MY_BITMAP *partial_match_key_parts)
{
ulonglong pm_buff_size;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
DBUG_ASSERT(strategy == PARTIAL_MATCH);
/*
Choose according to global optimizer switch. If only one of the switches is
'ON', then the remaining strategy is the only possible one. The only cases
when this will be overriden is when the total size of all buffers for the
merge strategy is bigger than the 'rowid_merge_buff_size' system variable,
or if there isn't enough physical memory to allocate the buffers.
*/
if (!optimizer_flag(thd, OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE) &&
optimizer_flag(thd, OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN))
strategy= PARTIAL_MATCH_SCAN;
else if
( optimizer_flag(thd, OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE) &&
!optimizer_flag(thd, OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN))
strategy= PARTIAL_MATCH_MERGE;
/*
If both switches are ON, or both are OFF, we interpret that as "let the
optimizer decide". Perform a cost based choice between the two partial
matching strategies.
*/
/*
TIMOUR: the above interpretation of the switch values could be changed to:
- if both are ON - let the optimizer decide,
- if both are OFF - do not use partial matching, therefore do not use
materialization in non-top-level predicates.
The problem with this is that we know for sure if we need partial matching
only after the subquery is materialized, and this is too late to revert to
the IN=>EXISTS strategy.
*/
if (strategy == PARTIAL_MATCH)
{
/*
TIMOUR: Currently we use a super simplistic measure. This will be
addressed in a separate task.
*/
if (tmp_table->file->stats.records < 100)
strategy= PARTIAL_MATCH_SCAN;
else
strategy= PARTIAL_MATCH_MERGE;
}
/* Check if there is enough memory for the rowid merge strategy. */
if (strategy == PARTIAL_MATCH_MERGE)
{
pm_buff_size= rowid_merge_buff_size(has_non_null_key,
has_covering_null_row,
partial_match_key_parts);
if (pm_buff_size > thd->variables.rowid_merge_buff_size)
strategy= PARTIAL_MATCH_SCAN;
}
}
/*
Compute the memory size of all buffers proportional to the number of rows
in tmp_table.
@details
If the result is bigger than thd->variables.rowid_merge_buff_size, partial
matching via merging is not applicable.
*/
ulonglong subselect_hash_sj_engine::rowid_merge_buff_size(
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
bool has_non_null_key, bool has_covering_null_row,
MY_BITMAP *partial_match_key_parts)
{
/* Total size of all buffers used by partial matching. */
ulonglong buff_size;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
ha_rows row_count= tmp_table->file->stats.records;
uint rowid_length= tmp_table->file->ref_length;
select_materialize_with_stats *result_sink=
(select_materialize_with_stats *) result;
ha_rows max_null_row;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/* Size of the subselect_rowid_merge_engine::row_num_to_rowid buffer. */
buff_size= row_count * rowid_length * sizeof(uchar);
if (has_non_null_key)
{
/* Add the size of Ordered_key::key_buff of the only non-NULL key. */
buff_size+= row_count * sizeof(rownum_t);
}
if (!has_covering_null_row)
{
for (uint i= 0; i < partial_match_key_parts->n_bits; i++)
{
if (!bitmap_is_set(partial_match_key_parts, i) ||
result_sink->get_null_count_of_col(i) == row_count)
continue; /* In these cases we wouldn't construct Ordered keys. */
/* Add the size of Ordered_key::key_buff */
buff_size+= (row_count - result_sink->get_null_count_of_col(i)) *
sizeof(rownum_t);
/* Add the size of Ordered_key::null_key */
max_null_row= result_sink->get_max_null_of_col(i);
if (max_null_row >= UINT_MAX)
{
/*
There can be at most UINT_MAX bits in a MY_BITMAP that is used to
store NULLs in an Ordered_key. Return a number of bytes bigger than
the maximum allowed memory buffer for partial matching to disable
the rowid merge strategy.
*/
return ULONGLONG_MAX;
}
buff_size+= bitmap_buffer_size(max_null_row);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
}
}
return buff_size;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
/*
Initialize a MY_BITMAP with a buffer allocated on the current
memory root.
TIMOUR: move to bitmap C file?
*/
static my_bool
bitmap_init_memroot(MY_BITMAP *map, uint n_bits, MEM_ROOT *mem_root)
{
my_bitmap_map *bitmap_buf;
if (!(bitmap_buf= (my_bitmap_map*) alloc_root(mem_root,
bitmap_buffer_size(n_bits))) ||
bitmap_init(map, bitmap_buf, n_bits, FALSE))
return TRUE;
bitmap_clear_all(map);
return FALSE;
}
/**
Create all structures needed for IN execution that can live between PS
reexecution.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
@param tmp_columns the items that produce the data for the temp table
@param subquery_id subquery's identifier (to make "<subquery%d>" name for
EXPLAIN)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
@details
- Create a temporary table to store the result of the IN subquery. The
temporary table has one hash index on all its columns.
- Create a new result sink that sends the result stream of the subquery to
the temporary table,
@notice:
Currently Item_subselect::init() already chooses and creates at parse
time an engine with a corresponding JOIN to execute the subquery.
@retval TRUE if error
@retval FALSE otherwise
*/
2011-05-25 17:31:13 +02:00
bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id)
{
select_union *result_sink;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/* Options to create_tmp_table. */
ulonglong tmp_create_options= thd->options | TMP_TABLE_ALL_COLUMNS;
/* | TMP_TABLE_FORCE_MYISAM; TIMOUR: force MYISAM */
DBUG_ENTER("subselect_hash_sj_engine::init");
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (bitmap_init_memroot(&non_null_key_parts, tmp_columns->elements,
thd->mem_root) ||
bitmap_init_memroot(&partial_match_key_parts, tmp_columns->elements,
thd->mem_root))
DBUG_RETURN(TRUE);
/*
Create and initialize a select result interceptor that stores the
result stream in a temporary table. The temporary table itself is
managed (created/filled/etc) internally by the interceptor.
*/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
TIMOUR:
Select a more efficient result sink when we know there is no need to collect
data statistics.
if (strategy == COMPLETE_MATCH)
{
if (!(result= new select_union))
DBUG_RETURN(TRUE);
}
else if (strategy == PARTIAL_MATCH)
{
if (!(result= new select_materialize_with_stats))
DBUG_RETURN(TRUE);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
*/
if (!(result_sink= new select_materialize_with_stats))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
DBUG_RETURN(TRUE);
2011-05-25 17:31:13 +02:00
char buf[32];
uint len= my_snprintf(buf, sizeof(buf), "<subquery%d>", subquery_id);
char *name;
if (!(name= (char*)thd->alloc(len + 1)))
DBUG_RETURN(TRUE);
memcpy(name, buf, len+1);
result_sink->get_tmp_table_param()->materialized_subquery= true;
if (item->substype() == Item_subselect::IN_SUBS &&
((Item_in_subselect*)item)->is_jtbm_merged)
{
result_sink->get_tmp_table_param()->force_not_null_cols= true;
}
if (result_sink->create_result_table(thd, tmp_columns, TRUE,
tmp_create_options,
name, TRUE, TRUE))
DBUG_RETURN(TRUE);
tmp_table= result_sink->table;
result= result_sink;
/*
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
If the subquery has blobs, or the total key lenght is bigger than
some length, or the total number of key parts is more than the
allowed maximum (currently MAX_REF_PARTS == 16), then the created
index cannot be used for lookups and we can't use hash semi
join. If this is the case, delete the temporary table since it
will not be used, and tell the caller we failed to initialize the
engine.
*/
if (tmp_table->s->keys == 0)
{
//fprintf(stderr, "Q: %s\n", current_thd->query());
DBUG_ASSERT(0);
DBUG_ASSERT(
tmp_table->s->uniques ||
tmp_table->key_info->key_length >= tmp_table->file->max_key_length() ||
tmp_table->key_info->key_parts > tmp_table->file->max_key_parts());
free_tmp_table(thd, tmp_table);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
tmp_table= NULL;
delete result;
result= NULL;
DBUG_RETURN(TRUE);
}
/*
Make sure there is only one index on the temp table, and it doesn't have
the extra key part created when s->uniques > 0.
*/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
DBUG_ASSERT(tmp_table->s->keys == 1 &&
((Item_in_subselect *) item)->left_expr->cols() ==
tmp_table->key_info->key_parts);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
if (make_semi_join_conds() ||
/* A unique_engine is used both for complete and partial matching. */
!(lookup_engine= make_unique_engine()))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
DBUG_RETURN(TRUE);
/*
Repeat name resolution for 'cond' since cond is not part of any
clause of the query, and it is not 'fixed' during JOIN::prepare.
*/
if (semi_join_conds && !semi_join_conds->fixed &&
semi_join_conds->fix_fields(thd, (Item**)&semi_join_conds))
DBUG_RETURN(TRUE);
/* Let our engine reuse this query plan for materialization. */
materialize_join= materialize_engine->join;
materialize_join->change_result(result);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
DBUG_RETURN(FALSE);
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
Create an artificial condition to post-filter those rows matched by index
lookups that cannot be distinguished by the index lookup procedure.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
@notes
The need for post-filtering may occur e.g. because of
truncation. Prepared statements execution requires that fix_fields is
called for every execution. In order to call fix_fields we need to
create a Name_resolution_context and a corresponding TABLE_LIST for
the temporary table for the subquery, so that all column references
to the materialized subquery table can be resolved correctly.
@returns
@retval TRUE memory allocation error occurred
@retval FALSE the conditions were created and resolved (fixed)
*/
bool subselect_hash_sj_engine::make_semi_join_conds()
{
/*
Table reference for tmp_table that is used to resolve column references
(Item_fields) to columns in tmp_table.
*/
TABLE_LIST *tmp_table_ref;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/* Name resolution context for all tmp_table columns created below. */
Name_resolution_context *context;
Item_in_subselect *item_in= (Item_in_subselect *) item;
DBUG_ENTER("subselect_hash_sj_engine::make_semi_join_conds");
DBUG_ASSERT(semi_join_conds == NULL);
if (!(semi_join_conds= new Item_cond_and))
DBUG_RETURN(TRUE);
if (!(tmp_table_ref= (TABLE_LIST*) thd->alloc(sizeof(TABLE_LIST))))
DBUG_RETURN(TRUE);
tmp_table_ref->init_one_table("", tmp_table->alias.c_ptr(), TL_READ);
tmp_table_ref->table= tmp_table;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
context= new Name_resolution_context;
context->init();
context->first_name_resolution_table=
context->last_name_resolution_table= tmp_table_ref;
semi_join_conds_context= context;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
for (uint i= 0; i < item_in->left_expr->cols(); i++)
{
Item_func_eq *eq_cond; /* New equi-join condition for the current column. */
/* Item for the corresponding field from the materialized temp table. */
Item_field *right_col_item;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (!(right_col_item= new Item_field(thd, context, tmp_table->field[i])) ||
!(eq_cond= new Item_func_eq(item_in->left_expr->element_index(i),
right_col_item)) ||
(((Item_cond_and*)semi_join_conds)->add(eq_cond)))
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
delete semi_join_conds;
semi_join_conds= NULL;
DBUG_RETURN(TRUE);
}
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
if (semi_join_conds->fix_fields(thd, (Item**)&semi_join_conds))
DBUG_RETURN(TRUE);
DBUG_RETURN(FALSE);
}
/**
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
Create a new uniquesubquery engine for the execution of an IN predicate.
@details
Create and initialize a new JOIN_TAB, and Table_ref objects to perform
lookups into the indexed temporary table.
@retval A new subselect_hash_sj_engine object
@retval NULL if a memory allocation error occurs
*/
subselect_uniquesubquery_engine*
subselect_hash_sj_engine::make_unique_engine()
{
Item_in_subselect *item_in= (Item_in_subselect *) item;
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
Item_iterator_row it(item_in->left_expr);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/* The only index on the temporary table. */
KEY *tmp_key= tmp_table->key_info;
JOIN_TAB *tab;
DBUG_ENTER("subselect_hash_sj_engine::make_unique_engine");
/*
Create and initialize the JOIN_TAB that represents an index lookup
plan operator into the materialized subquery result. Notice that:
- this JOIN_TAB has no corresponding JOIN (and doesn't need one), and
- here we initialize only those members that are used by
subselect_uniquesubquery_engine, so these objects are incomplete.
*/
if (!(tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB))))
DBUG_RETURN(NULL);
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
tab->table= tmp_table;
tab->preread_init_done= FALSE;
Subquery cache (MWL#66) added. libmysqld/Makefile.am: The new file added. mysql-test/r/index_merge_myisam.result: subquery_cache optimization option added. mysql-test/r/myisam_mrr.result: subquery_cache optimization option added. mysql-test/r/subquery_cache.result: The subquery cache tests added. mysql-test/r/subselect3.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect3_jcl6.result: Subquery cache switched off to avoid changing read statistics. mysql-test/r/subselect_no_mat.result: subquery_cache optimization option added. mysql-test/r/subselect_no_opts.result: subquery_cache optimization option added. mysql-test/r/subselect_no_semijoin.result: subquery_cache optimization option added. mysql-test/r/subselect_sj.result: subquery_cache optimization option added. mysql-test/r/subselect_sj_jcl6.result: subquery_cache optimization option added. mysql-test/t/subquery_cache.test: The subquery cache tests added. mysql-test/t/subselect3.test: Subquery cache switched off to avoid changing read statistics. sql/CMakeLists.txt: The new file added. sql/Makefile.am: The new files added. sql/item.cc: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item.h: Expression cache item (Item_cache_wrapper) added. Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP. sql/item_cmpfunc.cc: Subquery cache added. sql/item_cmpfunc.h: Subquery cache added. sql/item_subselect.cc: Subquery cache added. sql/item_subselect.h: Subquery cache added. sql/item_sum.cc: Registration of subquery parameters added. sql/mysql_priv.h: subquery_cache optimization option added. sql/mysqld.cc: subquery_cache optimization option added. sql/opt_range.cc: Fix due to subquery cache. sql/opt_subselect.cc: Parameters of the function cahnged. sql/procedure.h: .h file guard added. sql/sql_base.cc: Registration of subquery parameters added. sql/sql_class.cc: Option to allow add indeces to temporary table. sql/sql_class.h: Item iterators added. Option to allow add indeces to temporary table. sql/sql_expression_cache.cc: Expression cache for caching subqueries added. sql/sql_expression_cache.h: Expression cache for caching subqueries added. sql/sql_lex.cc: Registration of subquery parameters added. sql/sql_lex.h: Registration of subqueries and subquery parameters added. sql/sql_select.cc: Subquery cache added. sql/sql_select.h: Subquery cache added. sql/sql_union.cc: A new parameter to the function added. sql/sql_update.cc: A new parameter to the function added. sql/table.cc: Procedures to manage temporarty tables index added. sql/table.h: Procedures to manage temporarty tables index added. storage/maria/ha_maria.cc: Fix of handler to allow destoy a table in case of error during the table creation. storage/maria/ha_maria.h: .h file guard added. storage/myisam/ha_myisam.cc: Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 12:37:30 +02:00
tab->ref.tmp_table_index_lookup_init(thd, tmp_key, it, FALSE);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
DBUG_RETURN(new subselect_uniquesubquery_engine(thd, tab, item,
semi_join_conds));
}
subselect_hash_sj_engine::~subselect_hash_sj_engine()
{
delete lookup_engine;
delete result;
if (tmp_table)
free_tmp_table(thd, tmp_table);
}
int subselect_hash_sj_engine::prepare()
{
/*
Create and optimize the JOIN that will be used to materialize
the subquery if not yet created.
*/
return materialize_engine->prepare();
}
/**
Cleanup performed after each PS execution.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
@details
Called in the end of JOIN::prepare for PS from Item_subselect::cleanup.
*/
void subselect_hash_sj_engine::cleanup()
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
enum_engine_type lookup_engine_type= lookup_engine->engine_type();
is_materialized= FALSE;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
bitmap_clear_all(&non_null_key_parts);
bitmap_clear_all(&partial_match_key_parts);
count_partial_match_columns= 0;
count_null_only_columns= 0;
strategy= UNDEFINED;
materialize_engine->cleanup();
/*
Restore the original Item_in_subselect engine. This engine is created once
at parse time and stored across executions, while all other materialization
related engines are created and chosen for each execution.
*/
((Item_in_subselect *) item)->engine= materialize_engine;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
if (lookup_engine_type == TABLE_SCAN_ENGINE ||
lookup_engine_type == ROWID_MERGE_ENGINE)
{
subselect_engine *inner_lookup_engine;
inner_lookup_engine=
((subselect_partial_match_engine*) lookup_engine)->lookup_engine;
/*
Partial match engines are recreated for each PS execution inside
subselect_hash_sj_engine::exec().
*/
delete lookup_engine;
lookup_engine= inner_lookup_engine;
}
DBUG_ASSERT(lookup_engine->engine_type() == UNIQUESUBQUERY_ENGINE);
lookup_engine->cleanup();
result->cleanup(); /* Resets the temp table as well. */
DBUG_ASSERT(tmp_table);
free_tmp_table(thd, tmp_table);
tmp_table= NULL;
}
/*
Get fanout produced by tables specified in the table_map
*/
double get_fanout_with_deps(JOIN *join, table_map tset)
{
/* Handle the case of "Impossible WHERE" */
if (join->table_count == 0)
return 0.0;
/* First, recursively get all tables we depend on */
table_map deps_to_check= tset;
table_map checked_deps= 0;
table_map further_deps;
do
{
further_deps= 0;
Table_map_iterator tm_it(deps_to_check);
int tableno;
while ((tableno = tm_it.next_bit()) != Table_map_iterator::BITMAP_END)
{
/* get tableno's dependency tables that are not in needed_set */
further_deps |= join->map2table[tableno]->ref.depend_map & ~checked_deps;
}
checked_deps |= deps_to_check;
deps_to_check= further_deps;
} while (further_deps != 0);
/* Now, walk the join order and calculate the fanout */
double fanout= 1;
for (JOIN_TAB *tab= first_top_level_tab(join, WITHOUT_CONST_TABLES); tab;
tab= next_top_level_tab(join, tab))
{
/*
Ignore SJM nests. They have tab->table==NULL. There is no point to walk
inside them, because GROUP BY clause cannot refer to tables from within
subquery.
*/
if (!tab->is_sjm_nest() && (tab->table->map & checked_deps) &&
!tab->emb_sj_nest &&
tab->records_read != 0)
{
fanout *= rows2double(tab->records_read);
}
}
return fanout;
}
#if 0
void check_out_index_stats(JOIN *join)
{
ORDER *order;
uint n_order_items;
/*
First, collect the keys that we can use in each table.
We can use a key if
- all tables refer to it.
*/
key_map key_start_use[MAX_TABLES];
key_map key_infix_use[MAX_TABLES];
table_map key_used=0;
table_map non_key_used= 0;
bzero(&key_start_use, sizeof(key_start_use)); //psergey-todo: safe initialization!
bzero(&key_infix_use, sizeof(key_infix_use));
for (order= join->group_list; order; order= order->next)
{
Item *item= order->item[0];
if (item->real_type() == Item::FIELD_ITEM)
{
if (item->used_tables() & OUTER_REF_TABLE_BIT)
continue; /* outside references are like constants for us */
Field *field= ((Item_field*)item->real_item())->field;
uint table_no= field->table->tablenr;
if (!(non_key_used && table_map(1) << table_no) &&
!field->part_of_key.is_clear_all())
{
key_map infix_map= field->part_of_key;
infix_map.subtract(field->key_start);
key_start_use[table_no].merge(field->key_start);
key_infix_use[table_no].merge(infix_map);
key_used |= table_no;
}
continue;
}
/*
Note: the below will cause clauses like GROUP BY YEAR(date) not to be
handled.
*/
non_key_used |= item->used_tables();
}
Table_map_iterator tm_it(key_used & ~non_key_used);
int tableno;
while ((tableno = tm_it.next_bit()) != Table_map_iterator::BITMAP_END)
{
key_map::iterator key_it(key_start_use);
int keyno;
while ((keyno = tm_it.next_bit()) != key_map::iterator::BITMAP_END)
{
for (order= join->group_list; order; order= order->next)
{
Item *item= order->item[0];
if (item->used_tables() & (table_map(1) << tableno))
{
DBUG_ASSERT(item->real_type() == Item::FIELD_ITEM);
}
}
/*
if (continuation)
{
walk through list and find which key parts are occupied;
// note that the above can't be made any faster.
}
else
use rec_per_key[0];
find out the cardinality.
check if cardinality decreases if we use it;
*/
}
}
}
#endif
2011-05-10 12:31:02 +02:00
/*
Get an estimate of how many records will be produced after the GROUP BY
operation.
@param join Join we're operating on
@param join_op_rows How many records will be produced by the join
operations (this is what join optimizer produces)
@seealso
See also optimize_semijoin_nests(), grep for "Adjust output cardinality
estimates". Very similar code there that is not joined with this one
because we operate on different data structs and too much effort is
needed to abstract them out.
@return
Number of records we expect to get after the GROUP BY operation
*/
double get_post_group_estimate(JOIN* join, double join_op_rows)
{
table_map tables_in_group_list= table_map(0);
/* Find out which tables are used in GROUP BY list */
for (ORDER *order= join->group_list; order; order= order->next)
{
Item *item= order->item[0];
if (item->used_tables() & RAND_TABLE_BIT)
{
/* Each join output record will be in its own group */
return join_op_rows;
}
tables_in_group_list|= item->used_tables();
}
tables_in_group_list &= ~PSEUDO_TABLE_BITS;
/*
Use join fanouts to calculate the max. number of records in the group-list
*/
double fanout_rows[MAX_KEY];
bzero(&fanout_rows, sizeof(fanout_rows));
double out_rows;
out_rows= get_fanout_with_deps(join, tables_in_group_list);
2011-05-10 12:31:02 +02:00
#if 0
/* The following will be needed when making use of index stats: */
/*
Also generate max. number of records for each of the tables mentioned
in the group-list. We'll use that a baseline number that we'll try to
reduce by using
- #table-records
- index statistics.
*/
Table_map_iterator tm_it(tables_in_group_list);
int tableno;
while ((tableno = tm_it.next_bit()) != Table_map_iterator::BITMAP_END)
{
fanout_rows[tableno]= get_fanout_with_deps(join, table_map(1) << tableno);
}
/*
Try to bring down estimates using index statistics.
*/
//check_out_index_stats(join);
2011-05-10 12:31:02 +02:00
#endif
return out_rows;
}
/**
Execute a subquery IN predicate via materialization.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
@details
If needed materialize the subquery into a temporary table, then
copmpute the predicate via a lookup into this table.
@retval TRUE if error
@retval FALSE otherwise
*/
int subselect_hash_sj_engine::exec()
{
Item_in_subselect *item_in= (Item_in_subselect *) item;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
SELECT_LEX *save_select= thd->lex->current_select;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
subselect_partial_match_engine *pm_engine= NULL;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
int res= 0;
DBUG_ENTER("subselect_hash_sj_engine::exec");
/*
Optimize and materialize the subquery during the first execution of
the subquery predicate.
*/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
thd->lex->current_select= materialize_engine->select_lex;
/* The subquery should be optimized, and materialized only once. */
DBUG_ASSERT(materialize_join->optimized && !is_materialized);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
materialize_join->exec();
if ((res= test(materialize_join->error || thd->is_fatal_error ||
thd->is_error())))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
goto err;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
TODO:
- Unlock all subquery tables as we don't need them. To implement this
we need to add new functionality to JOIN::join_free that can unlock
all tables in a subquery (and all its subqueries).
- The temp table used for grouping in the subquery can be freed
immediately after materialization (yet it's done together with
unlocking).
*/
is_materialized= TRUE;
/*
If the subquery returned no rows, the temporary table is empty, so we know
directly that the result of IN is FALSE. We first update the table
statistics, then we test if the temporary table for the query result is
empty.
*/
tmp_table->file->info(HA_STATUS_VARIABLE);
if (!tmp_table->file->stats.records)
{
/* The value of IN will not change during this execution. */
item_in->reset();
item_in->make_const();
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
item_in->set_first_execution();
DBUG_RETURN(FALSE);
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/*
TIMOUR: The schema-based analysis for partial matching can be done once for
prepared statement and remembered. It is done here to remove the need to
save/restore all related variables between each re-execution, thus making
the code simpler.
*/
strategy= get_strategy_using_schema();
/* This call may discover that we don't need partial matching at all. */
strategy= get_strategy_using_data();
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (strategy == PARTIAL_MATCH)
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
uint count_pm_keys; /* Total number of keys needed for partial matching. */
MY_BITMAP *nn_key_parts= NULL; /* Key parts of the only non-NULL index. */
uint count_non_null_columns= 0; /* Number of columns in nn_key_parts. */
bool has_covering_null_row;
bool has_covering_null_columns;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
select_materialize_with_stats *result_sink=
(select_materialize_with_stats *) result;
uint field_count= tmp_table->s->fields;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (count_partial_match_columns < field_count)
{
nn_key_parts= &non_null_key_parts;
count_non_null_columns= bitmap_bits_set(nn_key_parts);
}
has_covering_null_row= (result_sink->get_max_nulls_in_row() == field_count);
has_covering_null_columns= (count_non_null_columns +
count_null_only_columns == field_count);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (has_covering_null_row && has_covering_null_columns)
{
/*
The whole table consist of only NULL values. The result of IN is
a constant UNKNOWN.
*/
DBUG_ASSERT(tmp_table->file->stats.records == 1);
item_in->value= 0;
item_in->null_value= 1;
item_in->make_const();
item_in->set_first_execution();
DBUG_RETURN(FALSE);
}
if (has_covering_null_row)
{
DBUG_ASSERT(count_partial_match_columns = field_count);
count_pm_keys= 0;
}
else if (has_covering_null_columns)
count_pm_keys= 1;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
else
count_pm_keys= count_partial_match_columns - count_null_only_columns +
(nn_key_parts ? 1 : 0);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
choose_partial_match_strategy(test(nn_key_parts),
has_covering_null_row,
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
&partial_match_key_parts);
DBUG_ASSERT(strategy == PARTIAL_MATCH_MERGE ||
strategy == PARTIAL_MATCH_SCAN);
if (strategy == PARTIAL_MATCH_MERGE)
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
pm_engine=
new subselect_rowid_merge_engine(thd, (subselect_uniquesubquery_engine*)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
lookup_engine, tmp_table,
count_pm_keys,
has_covering_null_row,
has_covering_null_columns,
count_columns_with_nulls,
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
item, result,
semi_join_conds->argument_list());
if (!pm_engine ||
((subselect_rowid_merge_engine*) pm_engine)->
init(nn_key_parts, &partial_match_key_parts))
{
/*
The call to init() would fail if there was not enough memory to allocate
all buffers for the rowid merge strategy. In this case revert to table
scanning which doesn't need any big buffers.
*/
delete pm_engine;
pm_engine= NULL;
strategy= PARTIAL_MATCH_SCAN;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
if (strategy == PARTIAL_MATCH_SCAN)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
if (!(pm_engine=
new subselect_table_scan_engine(thd, (subselect_uniquesubquery_engine*)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
lookup_engine, tmp_table,
item, result,
semi_join_conds->argument_list(),
has_covering_null_row,
has_covering_null_columns,
count_columns_with_nulls)))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
/* This is an irrecoverable error. */
res= 1;
goto err;
}
}
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
if (pm_engine)
lookup_engine= pm_engine;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
item_in->change_engine(lookup_engine);
err:
thd->lex->current_select= save_select;
DBUG_RETURN(res);
}
/**
Print the state of this engine into a string for debugging and views.
*/
void subselect_hash_sj_engine::print(String *str, enum_query_type query_type)
{
str->append(STRING_WITH_LEN(" <materialize> ("));
materialize_engine->print(str, query_type);
str->append(STRING_WITH_LEN(" ), "));
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (lookup_engine)
lookup_engine->print(str, query_type);
else
str->append(STRING_WITH_LEN(
"<engine selected at execution time>"
));
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
void subselect_hash_sj_engine::fix_length_and_dec(Item_cache** row)
{
DBUG_ASSERT(FALSE);
}
void subselect_hash_sj_engine::exclude()
{
DBUG_ASSERT(FALSE);
}
bool subselect_hash_sj_engine::no_tables()
{
DBUG_ASSERT(FALSE);
return FALSE;
}
bool subselect_hash_sj_engine::change_result(Item_subselect *si,
select_result_interceptor *res,
bool temp __attribute__((unused)))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
DBUG_ASSERT(FALSE);
return TRUE;
}
Ordered_key::Ordered_key(uint keyid_arg, TABLE *tbl_arg, Item *search_key_arg,
ha_rows null_count_arg, ha_rows min_null_row_arg,
ha_rows max_null_row_arg, uchar *row_num_to_rowid_arg)
: keyid(keyid_arg), tbl(tbl_arg), search_key(search_key_arg),
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
row_num_to_rowid(row_num_to_rowid_arg), null_count(null_count_arg)
{
DBUG_ASSERT(tbl->file->stats.records > null_count);
key_buff_elements= tbl->file->stats.records - null_count;
cur_key_idx= HA_POS_ERROR;
DBUG_ASSERT((null_count && min_null_row_arg && max_null_row_arg) ||
(!null_count && !min_null_row_arg && !max_null_row_arg));
if (null_count)
{
/* The counters are 1-based, for key access we need 0-based indexes. */
min_null_row= min_null_row_arg - 1;
max_null_row= max_null_row_arg - 1;
}
else
min_null_row= max_null_row= 0;
}
Ordered_key::~Ordered_key()
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
my_free((char*) key_buff, MYF(0));
bitmap_free(&null_key);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
/*
Cleanup that needs to be done for each PS (re)execution.
*/
void Ordered_key::cleanup()
{
/*
Currently these keys are recreated for each PS re-execution, thus
there is nothing to cleanup, the whole object goes away after execution
is over. All handler related initialization/deinitialization is done by
the parent subselect_rowid_merge_engine object.
*/
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
Initialize a multi-column index.
*/
bool Ordered_key::init(MY_BITMAP *columns_to_index)
{
THD *thd= tbl->in_use;
uint cur_key_col= 0;
Item_field *cur_tmp_field;
Item_func_lt *fn_less_than;
key_column_count= bitmap_bits_set(columns_to_index);
key_columns= (Item_field**) thd->alloc(key_column_count *
sizeof(Item_field*));
compare_pred= (Item_func_lt**) thd->alloc(key_column_count *
sizeof(Item_func_lt*));
if (!key_columns || !compare_pred)
return TRUE; /* Revert to table scan partial match. */
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
for (uint i= 0; i < columns_to_index->n_bits; i++)
{
if (!bitmap_is_set(columns_to_index, i))
continue;
cur_tmp_field= new Item_field(tbl->field[i]);
/* Create the predicate (tmp_column[i] < outer_ref[i]). */
fn_less_than= new Item_func_lt(cur_tmp_field,
search_key->element_index(i));
fn_less_than->fix_fields(thd, (Item**) &fn_less_than);
key_columns[cur_key_col]= cur_tmp_field;
compare_pred[cur_key_col]= fn_less_than;
++cur_key_col;
}
if (alloc_keys_buffers())
{
/* TIMOUR revert to partial match via table scan. */
return TRUE;
}
return FALSE;
}
/*
Initialize a single-column index.
*/
bool Ordered_key::init(int col_idx)
{
THD *thd= tbl->in_use;
key_column_count= 1;
// TIMOUR: check for mem allocation err, revert to scan
key_columns= (Item_field**) thd->alloc(sizeof(Item_field*));
compare_pred= (Item_func_lt**) thd->alloc(sizeof(Item_func_lt*));
key_columns[0]= new Item_field(tbl->field[col_idx]);
/* Create the predicate (tmp_column[i] < outer_ref[i]). */
compare_pred[0]= new Item_func_lt(key_columns[0],
search_key->element_index(col_idx));
compare_pred[0]->fix_fields(thd, (Item**)&compare_pred[0]);
if (alloc_keys_buffers())
{
/* TIMOUR revert to partial match via table scan. */
return TRUE;
}
return FALSE;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/*
Allocate the buffers for both the row number, and the NULL-bitmap indexes.
*/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
bool Ordered_key::alloc_keys_buffers()
{
DBUG_ASSERT(key_buff_elements > 0);
if (!(key_buff= (rownum_t*) my_malloc((size_t)(key_buff_elements *
sizeof(rownum_t)), MYF(MY_WME))))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
return TRUE;
/*
TIMOUR: it is enough to create bitmaps with size
(max_null_row - min_null_row), and then use min_null_row as
lookup offset.
*/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/* Notice that max_null_row is max array index, we need count, so +1. */
if (bitmap_init(&null_key, NULL, (uint)(max_null_row + 1), FALSE))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
return TRUE;
cur_key_idx= HA_POS_ERROR;
return FALSE;
}
/*
Quick sort comparison function that compares two rows of the same table
indentfied with their row numbers.
@retval -1
@retval 0
@retval +1
*/
int
Ordered_key::cmp_keys_by_row_data(ha_rows a, ha_rows b)
{
uchar *rowid_a, *rowid_b;
int error, cmp_res;
/* The length in bytes of the rowids (positions) of tmp_table. */
uint rowid_length= tbl->file->ref_length;
if (a == b)
return 0;
/* Get the corresponding rowids. */
rowid_a= row_num_to_rowid + a * rowid_length;
rowid_b= row_num_to_rowid + b * rowid_length;
/* Fetch the rows for comparison. */
error= tbl->file->ha_rnd_pos(tbl->record[0], rowid_a);
DBUG_ASSERT(!error);
error= tbl->file->ha_rnd_pos(tbl->record[1], rowid_b);
DBUG_ASSERT(!error);
/*
Compare the two rows by the corresponding values of the indexed
columns.
*/
for (uint i= 0; i < key_column_count; i++)
{
Field *cur_field= key_columns[i]->field;
if ((cmp_res= cur_field->cmp_offset(tbl->s->rec_buff_length)))
return (cmp_res > 0 ? 1 : -1);
}
return 0;
}
int
Ordered_key::cmp_keys_by_row_data_and_rownum(Ordered_key *key,
rownum_t* a, rownum_t* b)
{
/* The result of comparing the two keys according to their row data. */
int cmp_row_res= key->cmp_keys_by_row_data(*a, *b);
if (cmp_row_res)
return cmp_row_res;
return (*a < *b) ? -1 : (*a > *b) ? 1 : 0;
}
void Ordered_key::sort_keys()
{
my_qsort2(key_buff, (size_t) key_buff_elements, sizeof(rownum_t),
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
(qsort2_cmp) &cmp_keys_by_row_data_and_rownum, (void*) this);
/* Invalidate the current row position. */
cur_key_idx= HA_POS_ERROR;
}
/*
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
The fraction of rows that do not contain NULL in the columns indexed by
this key.
@retval 1 if there are no NULLs
@retval 0 if only NULLs
*/
double Ordered_key::null_selectivity()
{
/* We should not be processing empty tables. */
DBUG_ASSERT(tbl->file->stats.records);
return (1 - (double) null_count / (double) tbl->file->stats.records);
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
Compare the value(s) of the current key in 'search_key' with the
data of the current table record.
@notes The comparison result follows from the way compare_pred
is created in Ordered_key::init. Currently compare_pred compares
a field in of the current row with the corresponding Item that
contains the search key.
@param row_num Number of the row (not index in the key_buff array)
@retval -1 if (current row < search_key)
@retval 0 if (current row == search_key)
@retval +1 if (current row > search_key)
*/
int Ordered_key::cmp_key_with_search_key(rownum_t row_num)
{
/* The length in bytes of the rowids (positions) of tmp_table. */
uint rowid_length= tbl->file->ref_length;
uchar *cur_rowid= row_num_to_rowid + row_num * rowid_length;
int error, cmp_res;
error= tbl->file->ha_rnd_pos(tbl->record[0], cur_rowid);
DBUG_ASSERT(!error);
for (uint i= 0; i < key_column_count; i++)
{
cmp_res= compare_pred[i]->get_comparator()->compare();
/* Unlike Arg_comparator::compare_row() here there should be no NULLs. */
DBUG_ASSERT(!compare_pred[i]->null_value);
if (cmp_res)
return (cmp_res > 0 ? 1 : -1);
}
return 0;
}
/*
Find a key in a sorted array of keys via binary search.
see create_subq_in_equalities()
*/
bool Ordered_key::lookup()
{
DBUG_ASSERT(key_buff_elements);
ha_rows lo= 0;
ha_rows hi= key_buff_elements - 1;
ha_rows mid;
int cmp_res;
while (lo <= hi)
{
mid= lo + (hi - lo) / 2;
cmp_res= cmp_key_with_search_key(key_buff[mid]);
/*
In order to find the minimum match, check if the pevious element is
equal or smaller than the found one. If equal, we need to search further
to the left.
*/
if (!cmp_res && mid > 0)
cmp_res= !cmp_key_with_search_key(key_buff[mid - 1]) ? 1 : 0;
if (cmp_res == -1)
{
/* row[mid] < search_key */
lo= mid + 1;
}
else if (cmp_res == 1)
{
/* row[mid] > search_key */
if (!mid)
goto not_found;
hi= mid - 1;
}
else
{
/* row[mid] == search_key */
cur_key_idx= mid;
return TRUE;
}
}
not_found:
cur_key_idx= HA_POS_ERROR;
return FALSE;
}
/*
Move the current index pointer to the next key with the same column
values as the current key. Since the index is sorted, all such keys
are contiguous.
*/
bool Ordered_key::next_same()
{
DBUG_ASSERT(key_buff_elements);
if (cur_key_idx < key_buff_elements - 1)
{
/*
TIMOUR:
The below is quite inefficient, since as a result we will fetch every
row (except the last one) twice. There must be a more efficient way,
e.g. swapping record[0] and record[1], and reading only the new record.
*/
if (!cmp_keys_by_row_data(key_buff[cur_key_idx], key_buff[cur_key_idx + 1]))
{
++cur_key_idx;
return TRUE;
}
}
return FALSE;
}
void Ordered_key::print(String *str)
{
uint i;
str->append("{idx=");
str->qs_append(keyid);
str->append(", (");
for (i= 0; i < key_column_count - 1; i++)
{
str->append(key_columns[i]->field->field_name);
str->append(", ");
}
str->append(key_columns[i]->field->field_name);
str->append("), ");
str->append("null_bitmap: (bits=");
str->qs_append(null_key.n_bits);
str->append(", nulls= ");
str->qs_append((double)null_count);
str->append(", min_null= ");
str->qs_append((double)min_null_row);
str->append(", max_null= ");
str->qs_append((double)max_null_row);
str->append("), ");
str->append('}');
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
subselect_partial_match_engine::subselect_partial_match_engine(
THD *thd_arg, subselect_uniquesubquery_engine *engine_arg,
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
TABLE *tmp_table_arg, Item_subselect *item_arg,
select_result_interceptor *result_arg,
List<Item> *equi_join_conds_arg,
bool has_covering_null_row_arg,
bool has_covering_null_columns_arg,
uint count_columns_with_nulls_arg)
:subselect_engine(thd_arg, item_arg, result_arg),
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
tmp_table(tmp_table_arg), lookup_engine(engine_arg),
equi_join_conds(equi_join_conds_arg),
has_covering_null_row(has_covering_null_row_arg),
has_covering_null_columns(has_covering_null_columns_arg),
count_columns_with_nulls(count_columns_with_nulls_arg)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{}
int subselect_partial_match_engine::exec()
{
Item_in_subselect *item_in= (Item_in_subselect *) item;
int copy_res, lookup_res;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/* Try to find a matching row by index lookup. */
copy_res= lookup_engine->copy_ref_key_simple();
if (copy_res == -1)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
/* The result is FALSE based on the outer reference. */
item_in->value= 0;
item_in->null_value= 0;
return 0;
}
else if (copy_res == 0)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
/* Search for a complete match. */
if ((lookup_res= lookup_engine->index_lookup()))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
/* An error occured during lookup(). */
item_in->value= 0;
item_in->null_value= 0;
return lookup_res;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
}
else if (item_in->value || !count_columns_with_nulls)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
/*
A complete match was found, the result of IN is TRUE.
If no match was found, and there are no NULLs in the materialized
subquery, then the result is guaranteed to be false because this
branch is executed when the outer reference has no NULLs as well.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
Notice: (this->item == lookup_engine->item)
*/
return 0;
}
}
if (has_covering_null_row)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
/*
If there is a NULL-only row that coveres all columns the result of IN
is UNKNOWN.
*/
item_in->value= 0;
/*
TIMOUR: which one is the right way to propagate an UNKNOWN result?
Should we also set empty_result_set= FALSE; ???
*/
//item_in->was_null= 1;
item_in->null_value= 1;
return 0;
}
/*
There is no complete match. Look for a partial match (UNKNOWN result), or
no match (FALSE).
*/
if (tmp_table->file->inited)
tmp_table->file->ha_index_end();
if (partial_match())
{
/* The result of IN is UNKNOWN. */
item_in->value= 0;
/*
TIMOUR: which one is the right way to propagate an UNKNOWN result?
Should we also set empty_result_set= FALSE; ???
*/
//item_in->was_null= 1;
item_in->null_value= 1;
}
else
{
/* The result of IN is FALSE. */
item_in->value= 0;
/*
TIMOUR: which one is the right way to propagate an UNKNOWN result?
Should we also set empty_result_set= FALSE; ???
*/
//item_in->was_null= 0;
item_in->null_value= 0;
}
return 0;
}
void subselect_partial_match_engine::print(String *str,
enum_query_type query_type)
{
/*
Should never be called as the actual engine cannot be known at query
optimization time.
DBUG_ASSERT(FALSE);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
*/
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
@param non_null_key_parts
@param partial_match_key_parts A union of all single-column NULL key parts.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
@retval FALSE the engine was initialized successfully
@retval TRUE there was some (memory allocation) error during initialization,
such errors should be interpreted as revert to other strategy
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
*/
bool
subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts,
MY_BITMAP *partial_match_key_parts)
{
/* The length in bytes of the rowids (positions) of tmp_table. */
uint rowid_length= tmp_table->file->ref_length;
ha_rows row_count= tmp_table->file->stats.records;
rownum_t cur_rownum= 0;
select_materialize_with_stats *result_sink=
(select_materialize_with_stats *) result;
uint cur_keyid= 0;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
Item_in_subselect *item_in= (Item_in_subselect*) item;
int error;
if (merge_keys_count == 0)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
DBUG_ASSERT(bitmap_bits_set(partial_match_key_parts) == 0 ||
has_covering_null_row);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/* There is nothing to initialize, we will only do regular lookups. */
return FALSE;
}
/*
If all nullable columns contain only NULLs, there must be one index
over all non-null columns.
*/
DBUG_ASSERT(!has_covering_null_columns ||
(has_covering_null_columns &&
merge_keys_count == 1 && non_null_key_parts));
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/*
Allocate buffers to hold the merged keys and the mapping between rowids and
row numbers. All small buffers are allocated in the runtime memroot. Big
buffers are allocated from the OS via malloc.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
*/
if (!(merge_keys= (Ordered_key**) thd->alloc(merge_keys_count *
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
sizeof(Ordered_key*))) ||
!(null_bitmaps= (MY_BITMAP**) thd->alloc(merge_keys_count *
sizeof(MY_BITMAP*))) ||
!(row_num_to_rowid= (uchar*) my_malloc((size_t)(row_count * rowid_length),
MYF(MY_WME))))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
return TRUE;
/* Create the only non-NULL key if there is any. */
if (non_null_key_parts)
{
non_null_key= new Ordered_key(cur_keyid, tmp_table, item_in->left_expr,
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
0, 0, 0, row_num_to_rowid);
if (non_null_key->init(non_null_key_parts))
return TRUE;
merge_keys[cur_keyid]= non_null_key;
merge_keys[cur_keyid]->first();
++cur_keyid;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
/*
If all nullable columns contain NULLs, the only key that is needed is the
only non-NULL key that is already created above.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
*/
if (!has_covering_null_columns)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
if (bitmap_init_memroot(&matching_keys, merge_keys_count, thd->mem_root) ||
bitmap_init_memroot(&matching_outer_cols, merge_keys_count, thd->mem_root))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
return TRUE;
/*
Create one single-column NULL-key for each column in
partial_match_key_parts.
*/
for (uint i= 0; i < partial_match_key_parts->n_bits; i++)
{
/* Skip columns that have no NULLs, or contain only NULLs. */
if (!bitmap_is_set(partial_match_key_parts, i) ||
result_sink->get_null_count_of_col(i) == row_count)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
continue;
merge_keys[cur_keyid]= new Ordered_key(
cur_keyid, tmp_table,
item_in->left_expr->element_index(i),
result_sink->get_null_count_of_col(i),
result_sink->get_min_null_of_col(i),
result_sink->get_max_null_of_col(i),
row_num_to_rowid);
if (merge_keys[cur_keyid]->init(i))
return TRUE;
merge_keys[cur_keyid]->first();
++cur_keyid;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
}
DBUG_ASSERT(cur_keyid == merge_keys_count);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/* Populate the indexes with data from the temporary table. */
if (tmp_table->file->ha_rnd_init_with_error(1))
return TRUE;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
tmp_table->file->extra_opt(HA_EXTRA_CACHE,
current_thd->variables.read_buff_size);
tmp_table->null_row= 0;
while (TRUE)
{
error= tmp_table->file->ha_rnd_next(tmp_table->record[0]);
if (error == HA_ERR_RECORD_DELETED)
{
/* We get this for duplicate records that should not be in tmp_table. */
continue;
}
/*
This is a temp table that we fully own, there should be no other
cause to stop the iteration than EOF.
*/
DBUG_ASSERT(!error || error == HA_ERR_END_OF_FILE);
if (error == HA_ERR_END_OF_FILE)
{
DBUG_ASSERT(cur_rownum == tmp_table->file->stats.records);
break;
}
/*
Save the position of this record in the row_num -> rowid mapping.
*/
tmp_table->file->position(tmp_table->record[0]);
memcpy(row_num_to_rowid + cur_rownum * rowid_length,
tmp_table->file->ref, rowid_length);
/* Add the current row number to the corresponding keys. */
if (non_null_key)
{
/* By definition there are no NULLs in the non-NULL key. */
non_null_key->add_key(cur_rownum);
}
for (uint i= (non_null_key ? 1 : 0); i < merge_keys_count; i++)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
/*
Check if the first and only indexed column contains NULL in the curent
row, and add the row number to the corresponding key.
*/
if (tmp_table->field[merge_keys[i]->get_field_idx(0)]->is_null())
merge_keys[i]->set_null(cur_rownum);
else
merge_keys[i]->add_key(cur_rownum);
}
++cur_rownum;
}
tmp_table->file->ha_rnd_end();
/* Sort all the keys by their NULL selectivity. */
my_qsort(merge_keys, merge_keys_count, sizeof(Ordered_key*),
(qsort_cmp) cmp_keys_by_null_selectivity);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/* Sort the keys in each of the indexes. */
for (uint i= 0; i < merge_keys_count; i++)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
merge_keys[i]->sort_keys();
if (init_queue(&pq, merge_keys_count, 0, FALSE,
Improved speed of thr_alarm from O(N) to O(1). thr_alarm is used to handle timeouts and kill of connections. Fixed compiler warnings. queues.h and queues.c are now based on the UNIREG code and thus made BSD. Fix code to use new queue() interface. This mostly affects how you access elements in the queue. If USE_NET_CLEAR is not set, don't clear connection from unexpected characters. This should give a speed up when doing a lot of fast queries. Fixed some code in ma_ft_boolean_search.c that had not made it from myisam/ft_boolean_search.c include/queues.h: Use UNIREG code base (BSD) Changed init_queue() to take all initialization arguments. New interface to access elements in queue include/thr_alarm.h: Changed to use time_t instead of ulong (portability) Added index_in_queue, to be able to remove random element from queue in O(1) mysys/queues.c: Use UNIREG code base (BSD) init_queue() and reinit_queue() now takes more initialization arguments. (No need for init_queue_ex() anymore) Now one can tell queue_insert() to store in the element a pointer to where element is in queue. This allows one to remove elements from queue in O(1) instead of O(N) mysys/thr_alarm.c: Use new option in queue() to allow fast removal of elements. Do less inside LOCK_alarm mutex. This should give a major speed up of thr_alarm usage when there is many threads sql/create_options.cc: Fixed wrong printf sql/event_queue.cc: Use new queue interface() sql/filesort.cc: Use new queue interface() sql/ha_partition.cc: Use new queue interface() sql/ha_partition.h: Fixed compiler warning sql/item_cmpfunc.cc: Fixed compiler warning sql/item_subselect.cc: Use new queue interface() Removed not used variable sql/net_serv.cc: If USE_NET_CLEAR is not set, don't clear connection from unexpected characters. This should give a speed up when doing a lot of fast queries at the disadvantage that if there is a bug in the client protocol the connection will be dropped instead of being unnoticed. sql/opt_range.cc: Use new queue interface() Fixed compiler warnings sql/uniques.cc: Use new queue interface() storage/maria/ma_ft_boolean_search.c: Copy code from myisam/ft_boolean_search.c Use new queue interface() storage/maria/ma_ft_nlq_search.c: Use new queue interface() storage/maria/ma_sort.c: Use new queue interface() storage/maria/maria_pack.c: Use new queue interface() Use queue_fix() instead of own loop to fix queue. storage/myisam/ft_boolean_search.c: Use new queue interface() storage/myisam/ft_nlq_search.c: Use new queue interface() storage/myisam/mi_test_all.sh: Remove temporary file from last run storage/myisam/myisampack.c: Use new queue interface() Use queue_fix() instead of own loop to fix queue. storage/myisam/sort.c: Use new queue interface() storage/myisammrg/myrg_queue.c: Use new queue interface() storage/myisammrg/myrg_rnext.c: Use new queue interface() storage/myisammrg/myrg_rnext_same.c: Use new queue interface() storage/myisammrg/myrg_rprev.c: Use new queue interface()
2010-07-16 09:33:01 +02:00
subselect_rowid_merge_engine::cmp_keys_by_cur_rownum, NULL,
0, 0))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
return TRUE;
return FALSE;
}
subselect_rowid_merge_engine::~subselect_rowid_merge_engine()
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/* None of the resources below is allocated if there are no ordered keys. */
if (merge_keys_count)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
my_free((char*) row_num_to_rowid, MYF(0));
for (uint i= 0; i < merge_keys_count; i++)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
delete merge_keys[i];
delete_queue(&pq);
if (tmp_table->file->inited == handler::RND)
tmp_table->file->ha_rnd_end();
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
void subselect_rowid_merge_engine::cleanup()
{
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
Quick sort comparison function to compare keys in order of decreasing bitmap
selectivity, so that the most selective keys come first.
@param k1 first key to compare
@param k2 second key to compare
@retval 1 if k1 is less selective than k2
@retval 0 if k1 is equally selective as k2
@retval -1 if k1 is more selective than k2
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
*/
int
subselect_rowid_merge_engine::cmp_keys_by_null_selectivity(Ordered_key **k1,
Ordered_key **k2)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
double k1_sel= (*k1)->null_selectivity();
double k2_sel= (*k2)->null_selectivity();
if (k1_sel < k2_sel)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
return 1;
if (k1_sel > k2_sel)
return -1;
return 0;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
/*
*/
int
subselect_rowid_merge_engine::cmp_keys_by_cur_rownum(void *arg,
uchar *k1, uchar *k2)
{
rownum_t r1= ((Ordered_key*) k1)->current();
rownum_t r2= ((Ordered_key*) k2)->current();
return (r1 < r2) ? -1 : (r1 > r2) ? 1 : 0;
}
/*
Check if certain table row contains a NULL in all columns for which there is
no match in the corresponding value index.
@note
There is no need to check the columns that contain only NULLs, because
those are guaranteed to match.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
@retval TRUE if a NULL row exists
@retval FALSE otherwise
*/
bool subselect_rowid_merge_engine::test_null_row(rownum_t row_num)
{
Ordered_key *cur_key;
for (uint i = 0; i < merge_keys_count; i++)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
cur_key= merge_keys[i];
if (bitmap_is_set(&matching_keys, cur_key->get_keyid()))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
/*
The key 'i' (with id 'cur_keyid') already matches a value in row
'row_num', thus we skip it as it can't possibly match a NULL.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
*/
continue;
}
if (!cur_key->is_null(row_num))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
return FALSE;
}
return TRUE;
}
/**
Test if a subset of NULL-able columns contains a row of NULLs.
@retval TRUE if such a row exists
@retval FALSE no complementing null row
*/
bool subselect_rowid_merge_engine::
exists_complementing_null_row(MY_BITMAP *keys_to_complement)
{
rownum_t highest_min_row= 0;
rownum_t lowest_max_row= UINT_MAX;
uint count_null_keys, i;
Ordered_key *cur_key;
if (!count_columns_with_nulls)
{
/*
If there are both NULLs and non-NUll values in the outer reference, and
the subquery contains no NULLs, a complementing NULL row cannot exist.
*/
return FALSE;
}
for (i= (non_null_key ? 1 : 0), count_null_keys= 0; i < merge_keys_count; i++)
{
cur_key= merge_keys[i];
if (bitmap_is_set(keys_to_complement, cur_key->get_keyid()))
continue;
if (!cur_key->get_null_count())
{
/* If there is column without NULLs, there cannot be a partial match. */
return FALSE;
}
if (cur_key->get_min_null_row() > highest_min_row)
highest_min_row= cur_key->get_min_null_row();
if (cur_key->get_max_null_row() < lowest_max_row)
lowest_max_row= cur_key->get_max_null_row();
null_bitmaps[count_null_keys++]= cur_key->get_null_key();
}
if (lowest_max_row < highest_min_row)
{
/* The intersection of NULL rows is empty. */
return FALSE;
}
return bitmap_exists_intersection((const MY_BITMAP**) null_bitmaps,
count_null_keys,
(uint)highest_min_row, (uint)lowest_max_row);
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
@retval TRUE there is a partial match (UNKNOWN)
@retval FALSE there is no match at all (FALSE)
*/
bool subselect_rowid_merge_engine::partial_match()
{
Ordered_key *min_key; /* Key that contains the current minimum position. */
rownum_t min_row_num; /* Current row number of min_key. */
Ordered_key *cur_key;
rownum_t cur_row_num;
uint count_nulls_in_search_key= 0;
uint max_null_in_any_row=
((select_materialize_with_stats *) result)->get_max_nulls_in_row();
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
bool res= FALSE;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/* If there is a non-NULL key, it must be the first key in the keys array. */
DBUG_ASSERT(!non_null_key || (non_null_key && merge_keys[0] == non_null_key));
/* The prioryty queue for keys must be empty. */
DBUG_ASSERT(!pq.elements);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/* All data accesses during execution are via handler::ha_rnd_pos() */
if (tmp_table->file->ha_rnd_init_with_error(0))
{
res= FALSE;
goto end;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/* Check if there is a match for the columns of the only non-NULL key. */
if (non_null_key && !non_null_key->lookup())
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
res= FALSE;
goto end;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
If all nullable columns contain only NULLs, then there is a guranteed
partial match, and we don't need to search for a matching row.
*/
if (has_covering_null_columns)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
res= TRUE;
goto end;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (non_null_key)
queue_insert(&pq, (uchar *) non_null_key);
/*
Do not add the non_null_key, since it was already processed above.
*/
bitmap_clear_all(&matching_outer_cols);
for (uint i= test(non_null_key); i < merge_keys_count; i++)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
DBUG_ASSERT(merge_keys[i]->get_column_count() == 1);
if (merge_keys[i]->get_search_key(0)->null_value)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
++count_nulls_in_search_key;
bitmap_set_bit(&matching_outer_cols, merge_keys[i]->get_keyid());
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
else if (merge_keys[i]->lookup())
queue_insert(&pq, (uchar *) merge_keys[i]);
}
/*
If the outer reference consists of only NULLs, or if it has NULLs in all
nullable columns (above we guarantee there is a match for the non-null
coumns), the result is UNKNOWN.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
*/
if (count_nulls_in_search_key == merge_keys_count - test(non_null_key))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
res= TRUE;
goto end;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
If the outer row has NULLs in some columns, and
there is no match for any of the remaining columns, and
there is a subquery row with NULLs in all unmatched columns,
then there is a partial match, otherwise the result is FALSE.
*/
if (count_nulls_in_search_key && !pq.elements)
{
DBUG_ASSERT(!non_null_key);
/*
Check if the intersection of all NULL bitmaps of all keys that
are not in matching_outer_cols is non-empty.
*/
res= exists_complementing_null_row(&matching_outer_cols);
goto end;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
/*
If there is no NULL (sub)row that covers all NULL columns, and there is no
match for any of the NULL columns, the result is FALSE. Notice that if there
is a non-null key, and there is only one matching key, the non-null key is
the matching key. This is so, because this method returns FALSE if the
non-null key doesn't have a match.
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
*/
if (!count_nulls_in_search_key &&
(!pq.elements ||
(pq.elements == 1 && non_null_key &&
max_null_in_any_row < merge_keys_count-1)))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
if (!pq.elements)
{
DBUG_ASSERT(!non_null_key);
/*
The case of a covering null row is handled by
subselect_partial_match_engine::exec()
*/
DBUG_ASSERT(max_null_in_any_row != tmp_table->s->fields);
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
res= FALSE;
goto end;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
DBUG_ASSERT(pq.elements);
min_key= (Ordered_key*) queue_remove_top(&pq);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
min_row_num= min_key->current();
bitmap_set_bit(&matching_keys, min_key->get_keyid());
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
bitmap_union(&matching_keys, &matching_outer_cols);
if (min_key->next_same())
queue_insert(&pq, (uchar *) min_key);
if (pq.elements == 0)
{
/*
Check the only matching row of the only key min_key for NULL matches
in the other columns.
*/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
res= test_null_row(min_row_num);
goto end;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
while (TRUE)
{
cur_key= (Ordered_key*) queue_remove_top(&pq);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
cur_row_num= cur_key->current();
if (cur_row_num == min_row_num)
bitmap_set_bit(&matching_keys, cur_key->get_keyid());
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
else
{
/* Follows from the correct use of priority queue. */
DBUG_ASSERT(cur_row_num > min_row_num);
if (test_null_row(min_row_num))
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{
res= TRUE;
goto end;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
else
{
min_key= cur_key;
min_row_num= cur_row_num;
bitmap_clear_all(&matching_keys);
bitmap_set_bit(&matching_keys, min_key->get_keyid());
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
bitmap_union(&matching_keys, &matching_outer_cols);
}
}
if (cur_key->next_same())
queue_insert(&pq, (uchar *) cur_key);
if (pq.elements == 0)
{
/* Check the last row of the last column in PQ for NULL matches. */
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
res= test_null_row(min_row_num);
goto end;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/* We should never get here - all branches must be handled explicitly above. */
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
DBUG_ASSERT(FALSE);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
end:
if (!has_covering_null_columns)
bitmap_clear_all(&matching_keys);
queue_remove_all(&pq);
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
tmp_table->file->ha_rnd_end();
return res;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
subselect_table_scan_engine::subselect_table_scan_engine(
THD *thd_arg, subselect_uniquesubquery_engine *engine_arg,
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
TABLE *tmp_table_arg,
Item_subselect *item_arg,
select_result_interceptor *result_arg,
List<Item> *equi_join_conds_arg,
bool has_covering_null_row_arg,
bool has_covering_null_columns_arg,
uint count_columns_with_nulls_arg)
:subselect_partial_match_engine(thd_arg, engine_arg, tmp_table_arg, item_arg,
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
result_arg, equi_join_conds_arg,
has_covering_null_row_arg,
has_covering_null_columns_arg,
count_columns_with_nulls_arg)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
{}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
/*
TIMOUR:
This method is based on subselect_uniquesubquery_engine::scan_table().
Consider refactoring somehow, 80% of the code is the same.
for each row_i in tmp_table
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
count_matches= 0;
for each row element row_i[j]
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
if (outer_ref[j] is NULL || row_i[j] is NULL || outer_ref[j] == row_i[j])
++count_matches;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
if (count_matches == outer_ref.elements)
return TRUE
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
return FALSE
*/
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
bool subselect_table_scan_engine::partial_match()
{
List_iterator_fast<Item> equality_it(*equi_join_conds);
Item *cur_eq;
uint count_matches;
int error;
bool res;
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
if (tmp_table->file->ha_rnd_init_with_error(1))
{
res= FALSE;
goto end;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
tmp_table->file->extra_opt(HA_EXTRA_CACHE,
current_thd->variables.read_buff_size);
for (;;)
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
error= tmp_table->file->ha_rnd_next(tmp_table->record[0]);
if (error) {
if (error == HA_ERR_RECORD_DELETED)
{
error= 0;
continue;
}
if (error == HA_ERR_END_OF_FILE)
{
error= 0;
break;
}
else
{
error= report_error(tmp_table, error);
break;
}
}
equality_it.rewind();
count_matches= 0;
while ((cur_eq= equality_it++))
{
DBUG_ASSERT(cur_eq->type() == Item::FUNC_ITEM &&
((Item_func*)cur_eq)->functype() == Item_func::EQ_FUNC);
if (!cur_eq->val_int() && !cur_eq->null_value)
break;
++count_matches;
}
if (count_matches == tmp_table->s->fields)
{
res= TRUE; /* Found a matching row. */
goto end;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
res= FALSE;
end:
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
tmp_table->file->ha_rnd_end();
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
return res;
}
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs * Implemented a second partial matching strategy via table scan. This strategy is a fallback when there is no memory for rowid merging. * Refactored the selection and creation of partial matching strategies, so that the choice of strategy is encapsulated in a separate method choose_partial_match_strategy(). * Refactored the representation of partial match strategies so that: - each strategy is represented by a polymorphic class, and - the base class for all partial match strategies contains common execution code. * Added an estimate of the memory needed for the rowid merge strategy, and the system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Fixed multiple problems with deallocation of resources by the partial match strategies. sql/mysql_priv.h: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". sql/mysqld.cc: * Added two optimizer_switch system variables to control the choice of partial match strategy: "partial_match_rowid_merge", "partial_match_table_scan". * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/set_var.cc: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. sql/sql_class.h: * Added a system variable "rowid_merge_buff_size" to control the maximum memory to be used by the rowid merge algorithm. support-files/build-tags: Newer versions of BZR require the recursive flag in order to list all files.
2010-03-09 11:14:06 +01:00
void subselect_table_scan_engine::cleanup()
{
MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs This patch implements correct NULL semantics for materialized subquery execution. The implementation has the following properties and main limitations: - It passes all query result tests, but fails a number of EXPLAIN tests because of changed plans. - The EXPLAIN output for partial matching is not decided yet. - It works only when all necessary indexes fit into main memory. Notice that these are not the general B-tree/Hash indexes, but instead much more compact ones, therefore this limitation may not be a problem in many practical cases. - It doesn't contain specialized tests. - In several places the implementation uses methods that are modified copies of other similar methods. These cases need to be refactored to avoid code duplication. - Add a test if the predicate is top-level just before deciding on partial matching. If it is top-level, use a more efficient exec method (index lookup). - Add sorting of indexes according to their selectivity. The code is almost there. - Needs more comments, and to sync existing ones with the implementation. sql/item_cmpfunc.h: Expose the Arg_comparator of a comparison predicate. This makes it possible to directly get the comparison result {-1,0,1}, which is not possible through the val_XXX() methods which "fold" such results into a boolean. sql/item_subselect.cc: The core of the implementation of MWL#68. sql/item_subselect.h: The core of the implementation of MWL#68. sql/opt_subselect.cc: Removed the limitation for materialized subquery execution that it is applicable only for top-level predicates. sql/sql_class.cc: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_class.h: New class select_materialize_with_stats that collects data statistics about the data being inserted into the target table. sql/sql_select.cc: - more complete initialization of the TABLE object of a temp table. - call setup_subquery_materialization at one more exit point.
2010-02-19 22:55:57 +01:00
}
Fixed LP BUG#800696. The problem was that optimizer removes some outer references (it they are constant for example) and the list of outer items built during prepare phase is not actual during execution phase when we need it as the cache parameters. First solution was use pointer on pointer on outer reference Item and initialize temporary table on demand. This solved most problem except case when optimiser also reduce Item which contains outer references ('OR' in this bug test suite). The solution is to build the list of outer reference items on execution phase (after optimization) on demand (just before temporary table creation) by walking Item tree and finding outer references among Item_ident (Item_field/Item_ref) and Item_sum items. Removed depends_on list (because it is not neede any mnore for the cache, in the place where it was used it replaced with upper_refs). Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references (or other expression parameters in future). mysql-test/r/subselect_cache.result: A new test added. mysql-test/r/subselect_scache.result: Changes in creating the cache and its paremeters order or adding arguments of aggregate function (which is a parameter also, but this has no influence on the result). mysql-test/t/subselect_cache.test: Added a new test. sql/item.cc: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. Item_cache_wrapper collect parameters befor initialization of its cache. sql/item.h: depends_on removed. Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/item_cmpfunc.cc: depends_on removed. Added processor (collect_outer_ref_processor) to collect outer references. sql/item_cmpfunc.h: Added processor (collect_outer_ref_processor) to collect outer references. sql/item_subselect.cc: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_subselect.h: depends_on removed. Added processor get_cache_parameters() method to collect outer references. sql/item_sum.cc: Added processor (collect_outer_ref_processor) method to collect outer references. sql/item_sum.h: Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references. sql/opt_range.cc: depends_on removed. sql/sql_base.cc: depends_on removed. sql/sql_class.h: New iterator added. sql/sql_expression_cache.cc: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_expression_cache.h: Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done). sql/sql_lex.cc: depends_on removed. sql/sql_lex.h: depends_on removed. sql/sql_list.h: Added add_unique method to add only unique elements to the list. sql/sql_select.cc: Support of new Item list added. sql/sql_select.h: Support of new Item list added.
2011-07-19 22:19:10 +02:00